Specifications
Concepts - 2
Line Labels
You can write a program to GOTO or gosub to a label instead of a line number. This makes for more readable code.
90 A3 = AIN(0)
100 GOSUB ..FILTER
110 IF FL > 138 THEN GOTO ..OVER_LIMIT
.
.
.
5460 ..FILTER
5470 FL=.875 FL+.125*A3
*
5480 RETURN
.
.
.
8950 ..OVER_LIMIT
8960 OUT 49,3 :’shut down
.
.
.
Using line labels makes it easier to review code. You would probably know what “FILTER” does before remembering the
line number it is on.
Line labels must be the first and only information on a line.
NOTE: Labels may not be used with ON GOTO, ON GOSUB, RESTORE, or RESUME.
When labels are used with GOTO, etc., no other statements may follow the label on the same line.
Debugging
CAMBASIC provides you with several methods to help debug your program. As with all debugging, technique is usually
more important than tools. See the Debugging Programs Chapter for more information.
Bit Manipulation
CAMBASIC has commands for manipulating and reading bits. The BIT statement and BIT function can modify and read
individual bits. In order to modify a bit at an I/O port, the port must first be read, the appropriate bit set and the byte
written back to the port. The BIT statement does this automatically. The BIT function reads back individual bits. It returns
a “1” or “0” to reflects the state of the bit.
Communications Ports
CAMBASIC supports two serial ports, COM1 (console) and COM2. Once the serial ports are configured, they can
simultaneously capture data in the background while the program executes. If the ON COM$ statement is used,
CAMBASIC will branch to the user’s routine to handle the incoming data when the message is complete.
Both ports also have output buffering. When the PRINT statement is executed, the characters to be printed are sent to the
multitasker and program execution continues at the next statement. The program does not wait until all the characters are
printed. This is especially useful when data is being transmitted at a low baud rate over a modem or radio link. The output
buffers are 255 characters long.