Previous | Contents | Index |
DECLARE LONG rec-num MAP (CUSREC) WORD cus_num & STRING cus_nam = 20, cus_add = 20, cus_city = 10, cus_zip = 9 OPEN "CUS_ACCT.DAT" FOR INPUT AS #1 & RELATIVE FIXED, ACCESS MODIFY, & MAP CUSREC INPUT "Which record number would you like to view";rec_num GET #1, RECORD REC_NUM, REGARDLESS PRINT "The customer's number is ";CUS_NUM PRINT "The customer's name is ";cus_nam PRINT "The customer's address is ";cus_add PRINT "The customer's city is ";cus_city PRINT "The customer's zip code is ";cus_zip CLOSE #1 END |
The GETRFA function returns the record's file address (RFA) of the last record accessed in an RMS file open on a specified channel.
DECLARE RFA R_ARRAY(1 TO 100) . . . FOR I% = 1% TO 100% PUT #1 R_ARRAY(I%) = GETRFA(1) NEXT I% |
The GOSUB statement transfers control to a specified line number or label and stores the location of the GOSUB statement for eventual return from the subroutine.
GOSUB subroutine_1 . . . subroutine_1: . . . RETURN |
The GOTO statement transfers control to a specified line number or label.
IF answer = 0 THEN GOTO done END IF . . . done: EXIT PROGRAM |
The handler statement marks the beginning of a detached handler.
Handler-name must be a valid BASIC identifier and must not be the same as any label, DEF, DEF*, SUB, FUNCTION or PICTURE name.
WHEN ERROR USE err_handler . . . END WHEN HANDLER err_handler IF ERR = 50 THEN PRINT "Insufficient data" RETRY ELSE EXIT HANDLER END IF END HANDLER |
The IF statement evaluates a conditional expression and transfers program control depending on the resulting value.
IF Update_flag = True THEN Weekly_salary = New_rate * 40.0 UPDATE #1 IF Dept <> New_dept THEN GET #1, KEY #1 EQ New_dept Dept_employees = Dept_employees + 1 UPDATE #1 END IF PRINT "Update complete" ELSE PRINT "Skipping update for this employee" END IF |
The INKEY$ function reads a single keystroke from a terminal opened on a specified channel and returns the typed character.
PROGRAM Inkey_demo DECLARE STRING KEYSTROKE Inkey_Loop: WHILE 1% KEYSTROKE = INKEY$(0%,WAIT) SELECT KEYSTROKE CASE '26'C PRINT "Ctrl/Z to exit" EXIT Inkey_Loop CASE CR,LF,VT,FF PRINT "Line terminator" CASE "PF1" TO "PF4" PRINT "P function key" CASE "E1" TO "E6", "F7" TO "F9", "F10" TO "F20" PRINT "VT200 function key" CASE "KP0" TO "KP9" PRINT "Application keypad key" CASE < SP PRINT "Control character" CASE '127'C PRINT "<DEL>" CASE ELSE PRINT 'Character is "'; KEYSTROKE; '"' END SELECT NEXT END PROGRAM |
The INPUT statement assigns values from your terminal or from a terminal-format file to program variables.
DECLARE STRING your_name INPUT "What is your name",your_name |
What is your name ? |
DECLARE STRING your_name INPUT "What is your name";your_name |
What is your name? |
DECLARE STRING var_1, & INTEGER var_2 INPUT "The first variable";var_1, "The second variable";var_2 |
Output
The first variable? name The second variable? 4 |
The INPUT LINE statement assigns a string value (including the line terminator in some cases) from a terminal or terminal-format file to a string variable.
DECLARE STRING your_name INPUT LINE "Name",your_name |
Name ? |
DECLARE STRING your_name INPUT LINE "Name";your_name |
Name? |
Hex code | ASCII char | Character name |
---|---|---|
0A | LF | Line Feed |
0B | VT | Vertical Tab |
0C | FF | Form Feed |
0D | CR | Carriage Return |
0D0A | CRLF | Carriage Return/Line Feed |
1B | ESC | Escape |
Previous | Next | Contents | Index |