PROGRAM CONTROL
- RUN [N]
- Run the program, from the first line or from line N
- LIST [A-B]
- Show the listing (or only lines A to B)
- NEW
- Erase the program and all variables
- END
- Stop the program (also STOP: stops and allows CONT)
- CONT
- Continue a program stopped by STOP or ESC
- REM TEXT
- Comment: ignored when the program runs
- GOTO N
- Jump to line N
- GOSUB N
- Call the subroutine at line N; it ends with RETURN
- RETURN
- Go back to just after the GOSUB
- IF C THEN …
- Run what follows THEN (a line number or statements) only if the condition C is true
- FOR V=A TO B [STEP S]
- Repeat up to the matching NEXT, V going from A to B by S (default 1)
- NEXT [V]
- End of the FOR loop
- ON X GOTO A,B,C
- Jump to the Xth line of the list (also ON … GOSUB)
SCREEN AND KEYBOARD
- PRINT A;B
- Display values. ; sticks them together, , jumps to the next column; ending the line with one of them keeps the cursor on the same line
- TAB(N) / SPC(N)
- Inside PRINT: go to column N / print N spaces
- PRINT CHR$(147)
- Clear the screen (CHR$(19) = cursor home)
- INPUT "TEXT";V
- Ask the user for a value and store it in V (V$ for text)
- GET K$
- Read one key without waiting: K$ is "" when no key was pressed
- POS(0)
- Current cursor column (0-39)
- POKE 646,C
- Text color 0-15 for the next characters
- POKE 53280,C
- Border color
- POKE 53281,C
- Background color
The screen is 40 columns x 25 rows. 16 colors: 0 black, 1 white, 2 red, 3 cyan, 4 purple, 5 green, 6 blue, 7 yellow, 8 orange, 9 brown, 10 light red, 11-12-15 greys, 13 light green, 14 light blue.
VARIABLES AND DATA
- A=5
- Number variable (LET A=5 also works)
- A$="HI"
- Text variable: the name ends with $
- DIM A(N)
- Create an array A(0) … A(N); DIM A(N,M) for two dimensions
- DATA 1,2,"X"
- List of values stored in the program
- READ A,B$
- Take the next values from the DATA lists
- RESTORE
- Read the DATA again from the beginning
- DEF FN F(X)=X*2
- Define your own function, used as FN F(3)
- + - * / ^
- Add, subtract, multiply, divide, power
- = < > <= >= <>
- Compare: equal, smaller, bigger, smaller or equal, bigger or equal, different
- AND OR NOT
- Combine conditions (also work bit by bit on numbers)
- TI / TIME
- Time counter in 1/60 s since power on
- ST / STATUS
- Result of the last file operation (0 = OK)
- TI$ / TIME$
- Clock as HHMMSS since power on
MATH FUNCTIONS
- INT(X)
- Whole part, rounded down: INT(3.7)=3
- ABS(X) / SGN(X)
- Absolute value / sign (-1, 0 or 1)
- SQR(X)
- Square root
- RND(1)
- Random number from 0 to 1. INT(RND(1)*6)+1 = a dice
- SIN COS TAN ATN
- Trigonometry, angles in radians
- EXP(X) / LOG(X)
- e to the power X / natural logarithm
TEXT FUNCTIONS
- LEN(A$)
- Number of characters
- LEFT$(A$,N)
- The first N characters
- RIGHT$(A$,N)
- The last N characters
- MID$(A$,S,N)
- N characters starting at position S (first = 1)
- ASC(A$)
- Code of the first character
- CHR$(N)
- Character with code N
- STR$(X)
- Number to text
- VAL(A$)
- Text to number (0 if not a number)
FILES AND DEVICES
- SAVE "NAME",8
- Save the program on the virtual disk (device 8, browser storage)
- LOAD "NAME",8
- Load a program from the disk; LOAD "$",8 then LIST = directory
- VERIFY "NAME",8
- Compare the program in memory with the one on disk
- OPEN L,8,SA,"N,S,W"
- Open file number L on the disk. ,S,W = write a sequential file, nothing = read (SA: 0 read, 1 write)
- PRINT#L,A$
- Write values into the open file L
- INPUT#L,A$
- Read the next line / value from file L
- GET#L,A$
- Read one character from file L
- CMD L
- Send everything PRINT displays to file L, until CLOSE L
- CLOSE L
- Close file L (a written file is only stored when closed)
DIR, SCRATCH and the SAVE/LOAD buttons are described in the TOOLS and FILES tabs.
MEMORY AND SYSTEM
- POKE A,V
- Write the value V (0-255) at memory address A
- PEEK(A)
- Read the byte at address A
- 1024 + ROW*40 + COL
- Screen memory: POKE it with a screen code to put a character
- 55296 + ROW*40 + COL
- Color memory: color of that character
- SYS A
- Only two ROM calls exist (no real CPU): SYS 64738 = reset, SYS 58692 = clear screen
- FRE(0)
- Free memory for the program
- WAIT A,M[,X]
- Pause until (PEEK(A) XOR X) AND M is not 0 (ESC breaks)
- USR(X)
- User routine call; here it simply returns X
- TRON / TROFF
- Show / hide the line numbers while the program runs
- CLR
- Clear the variables, keep the program
- NEW
- Erase everything
Files: see the FILES tab (SAVE, LOAD, DIR, OPEN, CLOSE …).
FIRST PROGRAM
Type these lines (each ends with RETURN), then RUN:
10 PRINT CHR$(147)
20 FOR I=1 TO 10
30 PRINT I;" X 7 =";I*7
40 NEXT
50 INPUT "YOUR NAME";N$
60 PRINT "HELLO, ";N$
A line typed without a number runs at once (direct mode). A line with a number is stored in the program.