Specifications
Programing Tips - 2
10. Spaces have no affect on speed since they are eliminated in the compiling process.
11. Data statements execute slowly. If you need large data tables, load them into RAM at the start of the program,
and access them with the PEEK function. While this is less convenient, it is faster.
12. The PRINT USING statement takes longer to execute than PRINT, as it must format before sending the
characters.
13. FPOKE and FPEEK are the fastest memory accesses. They move four bytes at a time. If you have enough
memory to store multiple bytes, then use these constructs rather than PEEK, POKE, DPEEK and DPOKE.
FPOKE A%,B% is more than twice as fast as
POKE A,B in an average program
14. Array handling is, by its nature, slow in any language. Avoid multi-dimension arrays when possible.
15. When possible, use the DO/ENDDO loop instead of the FOR/NEXT. It is much faster.
16. The most effective way to speed up a program is through good programming. Highly modular programs with
lots of subroutines and GOSUBs are easy to develop, read and maintain. However, they are slower than
optimizing program flow for speed.
17. When using a FOR/NEXT loop, avoid placing the variable after NEXT. This forces CAMBASIC to verify the
variable name and slow down execution of the loop.
10 NEXT fast
10 NEXT D slow
18. Do not use exponentiation to square or cube a number. It is a very slow operation.
10 A=Xˆ2 very slow
10 A=X*X fast
10 A=X*X*X better than xˆ3
Other Tips
1. Sometimes a system will crash without any obvious cause. The crashing can occur because part of the memory
used by CAMBASIC has been modified by a POKE statement that is out of bounds. For example,
10 POKE A,B
The variable A is the address at which the POKE occurs. If the value of A inadvertently falls into the wrong
area, unpredictable results may occur. Some of these are:
a. Error message for a nonexistent line number.
b. Erroneous error message for a good line.
c. A <System corruption> error message.
d. The system will not respond to the keyboard.
e. The program stops or locks up.
2. Software interrupts occur as a result of ON COUNT, ON KEYPAD$, ON BIT and similar statements. If a