Remote-processing CAMBASIC Manual de usuario Pagina 184

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 208
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 183
Program debugging - 1
PROGRAM DEBUGGING
CAM BASIC has several constructs which can be used to debug a program. This section will outline the methods and give
examples.
Using the STOP statement
When a STOP statement is encounter ed, progr am execution halts and the line number containing the stop statem ent is
displayed.
By inserting the STOP statement in different sections of the program, you can determ ine whether these sections are being
executed. For example, you can test a conditional branch:
10 INPUT A
20 IF A=2 THEN 50 ELSE 80
30 '
40 '
50 B=23
55 STOP
60 '
70 B=25
75 STOP
80 '
In this example, a line number followed by a remark ( ' ) statement means that this line would be a part of your program.
In the example above, STOP statements are inserted at lines 55 and 75 to determine if the branch at line 20 is operating
correctly. When you input 2, the progr am should stop at line 55. Otherwise, it should always stop at line 75.
USING THE PRINT AND INPUT STATEMENTS
The example above shows how the INPU T statement can be inserted so that you can m anually change the value of X to test
this progr am fragment.
The PRINT statement can also be used to print out the value of any variable or memory location after the program has
halted.
TRON/TROFF TRACES EXECUTION PATHS
TRON turns on the line num ber tracing function . L ine numbers ar e printed a s they are executed. No other information is
printed. However, all PRINT statements execute properly. Because the line numbers are printed, execution is slowed.
The slowdown is less noticeable at higher baud rates. To turn the trace off, execute TROFF.
Use TROFF to turn off the trace function. These two statements are most useful when tracing portions, rather than entire
programs. Below is a test program:
10 A$ = "Down"
20 TRON
30 FOR X = 0 TO 2
40 GOSUB 90
Vista de pagina 183
1 2 ... 179 180 181 182 183 184 185 186 187 188 189 ... 207 208

Comentarios a estos manuales

Sin comentarios