Optimizing BASIC programs
- Every line can use the maximum amount of 80 bytes. If you enter commands in a line, fill it up to the end and then press ENTER, the commands are converted to internal format and you can go on adding some bytes
- String expressions at the end of a line can be written without the ending ": PRINT "Text
- Memory wasting 2-character name variables can be deleted with CLEAR <name>: CLEAR AB
- You never need to write a THEN after an IF command, you only have to write LET for a following variable operation: IF X=10 PRINT X but IF X=10 LET X=0
- Brackets round expressions are only necessary if the command needs more than one expression (like MID$(...), RIGHT$(...) but CHR$ 13)
- INPUT and PRINT can take more than one expression with "," but PRINT writes the values in two columns and you can't use a semicolon ";": PRINT X,Y or PRINT X;":";Y or INPUT "Text: ";X$,"Text2: ";Y$
- CURSOR becomes smaller with a single counter: 0 = 0,0; 95 = 23,3: CURSOR 24 instead of CURSOR 0,1
- For small memory usage use the single-letter variables A-Z($)
- Delete unused arrays with ERASE
- You can use DIM and ERASE with more arrays with ",": DIM I$(0)*80,F(9) und ERASE I$,F
- IF conditions can be written without brackets around them: IF X<9 AND y>10 ...
- IF accepts numbers and variables as conditions: <=0 false, >0 true: IF X PRINT...
- INKEY$ can be used like a normal string variable, i.e. in IF-conditions, it's empty when no key was pressed: IF INKEY$="" GOTO...
- GOTO and GOSUB can jump to numbers and letters which are given through variables: GOTO X$ (X$="A") or GOSUB X (X=10)
- ON ... GOTO/GOSUB can be used for case selections
- Sending data over the serial interface can be made with a LPRINT command after OPEN, too
- Lines on screen can be put together with LINE (x0,y0)-(x1,y1): LINE -(x2,y2): LINE -(x3,y3)
- Operator sequence: INT, MDF, STR$, CHR$, ABS, SGN, PEEK, etc. are used before + - * / and logical operators
- Operators + - * / are executed before AND OR NOT
- LINE sequence: LINE (X1,Y1)-(X2,Y2)(,X)(,pattern in hexadecimal format)(,B/BF)
- PRINT and GPRINT with a ";" at the end of the expression counts the cursor one position forwards (breaks the line with PRINT)
- Use the RESERVE mode to save time (@ makes such commands executed like enter!): F: IF or N: NEXT X@
- GOTO and GOSUB can jump to a string expression at the start of a line: GOTO "Calc" ... 100 "Calc"
- With some "," you can leave values in expressions unchanged while you change a certain one: OPEN ",,,,,&1A"
- The DEF key can start programs fast, labels can be written like this: 10 "A" CLS : WAIT 0 ...
- AREAD Var$ gives Var$ the value of the last printed value on the screen: DEF + A : 10 "A" AREAD I$
- You can save space when using PRINT = LPRINT to print your results. PRINT = PRINT stops this
- Variable definitions are faster with , as separator: A=1,B=2,C=4
The fastest commands of PC-1360:
- Use multiplikation instead of power (^)
- FOR .. NEXT (STEP ..)
- ASC, CHR$
- AND, OR, NOT
- INT, MDF, SGN, ABS
- ON .. GOTO/GOSUB
- VAL, STR$
Copyright © Simon Lehmayr (Parts of my page were made with the help of Laurent Duveau)
If this page has no navigation, click here.