Basic Commands and Statements (Continued) Basic Commands and Statements (Continued) COMMAND;' STATEMENT EXAMPLE PURPOSE COMMAND? STATEMENT EXAMPLE PURPOSE LOAD 10 LOAD Loads next encountered program or file, on built-in tape unit, into PET's memory. Loads program or file NAME into memory from built-in tape unit. Loads specified file NAME from device D. 30 VERIFY "NAME",D Verifies specified program NAME saved on device D by reading it and comparing it with program still in PET's memory. 20 LOAD "NAME" 30 LOAD "NAME",D Prints N spaces or blanks. OPEN 10 OPEN L Opens logical file L for read only from built-in tape unit. Opens logical file L for read only from device D.
Opens logical file L for command C from device D. Opens logical file L on device D. If device D accepts formatted files, file NAME is positioned for command. SPC FOR . . NEXT 10 FOR A - 1 TO 20 Loop control. Performs all instructions 10 SPC(N) 20 OPEN L,D between FOR and NEXT as many times as specified by index, In this example, *,he index variable is A. 30 OPEN L,D,C 90 NEXT A 40 OPEN L,D,C,"NAME" STEP 10 FOR A - 1 TO 20 51 EP 2 Step specifies size of increment to be added to index to increase or decrease its value towards the desired number of iterations. 10 PRINT POS(0) Prints next available print position (posi- tion of cursor on screen l.
90 NEXT A POS Prints value of A on display screen, Prints specified string on screen. Prints specified values or strings on screen, beginning in next available print position (pre-TABbed positions are in columns 10,20,30,40, etc.). If condition is 'TRUE,' instruction follow IF ... THEN 10 IF A = 10 THEN PRINT A ing 'THEN' (in this example, 'PRINT A' ) would be executed. Otherwise, the next statement in sequence is executed. PRINT 10 PRINT A 20 PRINT AS 30 PRINT A,A$ If condition is true, control is transferred IF ... GOTO 10 IF A=1 GOTO L Prints on specified values and strings on screen separated by 3 spaces if numeric, concatenated if string.
to specified line, Otherwise, the next statement, following the ) F . . GOTO, is executed 40 PRINT A;A$ Prints specified value on logical file L. Transfers control (jumps) to specified line, GOTO 50 PRINT #L,A Prints specified string on logical file L. 10 GOTO L skipping over intervening lines. 60 PRINT #L,A$ 10 READ A Obtains value of A from a DATA statement. Obtains string value of A from a DATA statement. Obtains specified values for strings and numeric variables from DATA statements. GOSUB 10 GOSUB L Begins execution of a subroutine which begins on a specified line. READ 20 READ AS ON ...
GOTO 10 ON A GOTO L,M,N Transfers control to specified line (in this 30 READ A,A$,B,B$ example, L,M, or N, depending on value of index A. 10 REM "COMMENT" Inserts non-executable comments in a program for documentation purposes. ON.. . GOSUB 10 ON A GOSUB L,M,N Begins execution of subroutine which REM Permits re-reading of DATA statements without re-running program. begins on line L,M, or N, depending on the value of index A. RESTORE 10 RESTORE Prints value of A in character position N+1 on screen. Prints string beginning in character position N+1 on screen. RETURN 9990 RETURN Subroutine exit; transfers control to the statement following most recent GOSUB directing transfer to the subroutine.
10 PRINT TAB(N);A TAB 20 PRINT TAB(N);A$ Verifies most recent program saved on built-in cassette by reading it and com paring it with program still in PET's memory. Verifies specified program NAME saved on built-in cassette by reading it and comparing it with program still in PET's memory. String Functions 1 2 ER I F Y FUNCTION EXAMPLE PURPOSE V E R I F Y ASC 10 A=ASC("XYZ") Returns integer value corresponding to ASCII code of first character in string. 20 VERIFY "NAME" CHRS 10 A$=CHR$(N) Returns character corresponding to ASCII code number. LEFT$ 10 ?LEFT$(X$,A) Returns leftmost A characters from string. LEN 10 ?LEN(X$) Returns length of string. 43 J 42