Basic Commands and Statements (Continued)
COMMAND;'
S T A T E M E N T
E X A M P L E
PURPOSE
LOAD
OPEN
POS
P R I N T
READ
R E M
RESTORE
TAB
V E R I F Y
42
10 LOAD
20 LOAD "NAME"
30 LOAD "NAME",D
10 OPEN L
2 0 O P E N L , D
30 OPEN L,D,C
4 0 O P E N L , D , C , " N A M E "
10 PRINT POS(0)
1 0 P R I N T A
2 0 P R I N T A S
3 0 P R I N T A , A $
40
P R I N T
A;A$
50 PRINT #L,A
6 0 P R I N T # L , A $
10 READ A
20 READ AS
3 0 R E A D A , A $ , B , B $
10 REM "COMMENT"
1 0 R E S T O R E
10 PRINT TAB(N);A
2 0 P R I N T T A B ( N ) ; A $
1 2
ER I F Y
20 VERIFY "NAME"
Loads next encountered program or file,
o n b u i l t - i n t a p e u n i t , i n t o P E T ' s m e m o r y .
Loads program or file NAME into memory
f r o m b u i l t - i n t a p e u n i t .
Loads specified file NAME from device D.
O p e n s l o g i c a l f i l e L f o r r e a d o n l y f r o m
built-in tape unit.
O p e n s l o g i c a l f i l e L f o r r e a d o n l y f r o m
device D.
O p e n s l o g i c a l f i l e L f o r c o m m a n d C f r o m
device D.
Opens logical file L on device D. If device
D accepts formatted files, file NAME is
positioned for command.
Prints next available print position (posi-
tion of cursor on screen l.
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.).
Prints on specified values and strings on
screen separated by 3 spaces if numeric,
concatenated if string.
Prints specified value on logical file L.
Prints specified string on logical file L.
Obtains value of A from a DATA
statement.
O b t a i n s s t r i n g v a l u e o f A f r o m a D A T A
statement.
Obtains specified values for strings and
numeric variables from DATA statements.
Inserts non-executable comments in a
program for documentation purposes.
Permits re-reading of DATA statements
without re-running program.
Prints value of A in character position
N+1 on screen.
Prints string beginning in character
position N+1 on screen.
Verifies most recent program saved on
built-in cassette by reading it and com
paring it with program still in PET's
m e m o r y .
Verifies specified program NAME saved
on built-in cassette by reading it and
c o m p a r i n g i t w i t h p r o g r a m s t i l l i n
PET's memory.
Basic Commands and Statements (Continued)
C O M M A N D ?
S T A T E M E N T
E X A M P L E
PURPOSE
SPC
30 VERIFY "NAME",D
10 SPC(N)
Verifies specified program NAME saved
o n d e v i c e D b y r e a d i n g i t a n d c o m p a r i n g
i t w i t h p r o g r a m s t i l l i n P E T ' s m e m o r y .
Prints N spaces or blanks.
F O R . . NEXT
1 0 F O R A
-
1 T O 2 0
L o o p c o n t r o l . P e r f o r m s a l l i n s t r u c t i o n s
STEP
90 NEXT A
1 0 F O R A - 1 T O 2 0 5 1 E P 2
b e t w e e n F O R a n d N E X T a s m a n y t i m e s
as specified by index, In this example,
*,he index variable is A.
Step specifies size of increment to be
added
90 NEXT A
10 IF A = 10 THEN PRINT A
to index to increase or decrease its value
t o w a r d s t h e d e s i r e d n u m b e r o f i t e r a t i o n s .
I f c o n d i t i o n i s ' T R U E , ' i n s t r u c t i o n
f o l l o w
I F . . . THEN
10 IF A=1 GOTO L
i n g ' T H E N ' ( i n t h i s e x a m p l e , ' P R I N T A '
)
w o u l d b e e x e c u t e d . O t h e r w i s e , t h e n e x t
statement in sequence is executed.
I f c o n d i t i o n i s t r u e , c o n t r o l i s t r a n s f e r r e d
I F . . . G O T O
10 GOTO L
to specified line, Otherwise, the next
s t a t e m e n t , f o l l o w i n g t h e ) F . . G O T O ,
is executed
T r a n s f e r s c o n t r o l ( j u m p s ) t o s p e c i f i e d
l i n e ,
G O T O
GOSUB
1 0 G O S U B L
skipping over intervening lines.
B e g i n s e x e c u t i o n o f a s u b r o u t i n e w h i c h
O N . . . G O T O
10 ON A GOTO L,M,N
begins on a specified line.
T r a n s f e r s c o n t r o l t o s p e c i f i e d l i n e ( i n t h i s
ON.. . G O S U B
1 0 O N A G O S U B L , M , N
e x a m p l e , L , M , o r N , d e p e n d i n g o n v a l u e
o f i n d e x A .
B e g i n s e x e c u t i o n o f s u b r o u t i n e w h i c h
RETURN
9 9 9 0 R E T U R N
b e g i n s o n l i n e L , M , o r N , d e p e n d i n g o n
the value of index A.
S u b r o u t i n e e x i t ; t r a n s f e r s c o n t r o l t o t h e
s t a t e m e n t f o l l o w i n g m o s t r e c e n t G O S U B
d i r e c t i n g t r a n s f e r t o t h e s u b r o u t i n e .
String Functions
F U N C T I O N
E X A M P L E
PURPOSE
ASC
10 A=ASC("XYZ")
Returns integer value corresponding to
ASCII code of first character in string.
CHRS
1 0 A $ = C H R $ ( N )
Returns character corresponding to ASCII
code number.
LEFT$
1 0 ? L E F T $ ( X $ , A )
Returns leftmost A characters from
string.
L E N
1 0 ? L E N ( X $ )
Returns length of string.
43
J