Previous | Contents | Index |
Example 2-14 Using SHOW CALLS in DEBUG system |
---|
for x = 1 to 100 do_something next x halt routine do_something a = x*2 end routine |
When the HALT statement executes, the console window will open. Type into the console window:
show calls |
The results displayed in the console will be:
show calls ---------- MAIN.5 halt Recently Called Routines : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something : DO_SOMETHING routine do_something -- |
SHOW CALLS is used to display the list of recently called routines to aid in debugging a program.
SHOW CALLS is normally used after a HALT statement has executed. When "SHOW CALLS" is typed into the console window, the list of recently called routines will print out. Note that when the program halts, the list of recently called routines is printed to the console window immediately as well (without using the SHOW CALLS command).
SHOW FILES |
To perform this example, in SPDEV open 'c:\sheerpower\samples\client_scan.spsrc' and insert a HALT statement after the end extract statement as shown below:
// Scan through vendors looking for name "kind of like" a given name. open structure vendor: name '@vendor', access outin // By default, lets look for GENEVIEVE -- so just enter in a few sample // letters that might be in the person's name -- like "GNVE " line input 'Enter part of a name', default 'gnve': scanfor$ scanfor$ = ucase$(scanfor$) total = 0 extract structure vendor include scan(vendor(name), scanfor$) > 0 print vendor(name); tab(30); vendor(phone);' '; vendor(city); print tab(60);vendor(balance) total = total + vendor(balance) end extract halt <-- insert HALT statement print '====================' print using 'Total: $#,###,###': total end |
Run the program by clicking on the running man icon in the SPDEV toolbar. The console window will open and display:
Enter part of a name? gnve |
Press the [Enter] key. The following will display in the console window:
DE GUZMAN, GENEVIEVE 6217239098 FALLBROOK 8591 BURCH, GENEVIEVE 7067289429 FALLBROOK 8798 Halt at MAIN.14 ---------- >>> MAIN.14 halt |
Now type in show files directly in the console window. The resulting full console window display is below:
Example 2-15 Show files after using the HALT command |
---|
Enter part of a name? gnve DE GUZMAN, GENEVIEVE 6217239098 FALLBROOK 8591 BURCH, GENEVIEVE 7067289429 FALLBROOK 8798 Halt at MAIN.14 ---------- >>> MAIN.14 halt show files Last status: Incorrect function. (0000006C) channel: 000 status: 00000001 00000001 name: sys$output open id: 1 flags : (t)input (t)output lock stream cancel locked : 1 row : 12 col : 67 pagelen: 30 reclen: 2048 margin: 80 zone : 20 cursize: 0 read : 13 write : 55 blocks: 186 control: 95 rewind: 0 update: 0 delete: 0 lun: 001 status: 00000001 00000000 name: c:\sheerpower\samples\vendor.ars open id: 3 flags : input output optimized locked : 0 row : 1 col : 1 pagelen: 0 reclen: 200 margin: 200 zone : 20 cursize: 8 read : 1384 write : 0 blocks: 0 control: 5 rewind: 1 update: 0 delete: 0 Current: 583 0 |
Use the SHOW FILES command after a program halts to display a list of all open files and their status.
SHOW FILES displays a list of all open files and their status. If the files are ARS files (tables) then it some information will be displayed about their key structure, and recordsize, etc.
GO |
Copy/Paste or type the following example into a new file inside SPDEV. Name it 'test.spsrc'.
Example 2-16 GO command |
---|
debug on for i = 1 to 6 print i if i = 4 then halt next i end |
Run the program by clicking once on the Run icon.
The following result will appear in the console window:
1 2 3 4 Halt at MAIN.0003 -- Call Stack Depth: 0 MAIN.0003 if i = 4 then halt -- Recently Called Routines -- |
GO is used to continue a program after it has been interrupted.
GO resumes program execution after it has been interrupted. Once execution has stopped, you can enter immediate mode and debug commands, change code, check values of variables and calculations, etc. GO lets you resume execution even after changing code. If a HALT or BREAK statement was used, execution resumes at the first statement after the halt or break.
You can type in the PRINT command as shown in the example below and press [Enter]. The value will be printed out as requested. You can then type the GO command in the console window and press [Enter]. The program will then resume execution.
1 2 3 4 Halt at MAIN.0003 -- Call Stack Depth: 0 MAIN.0003 if i = 4 then halt -- Recently Called Routines -- print sqr(i)//<---- type in this line and press [Enter] 2 go //<---- type in 'go' and press [Enter] 5 6 |
Sheerpower detects and announces exceptions and build errors. Sometimes errors occur which do not prevent execution, but do cause a program to execute incorrectly. Sheerpower provides a high-level DEBUG system for detecting these more subtle errors.
DEBUG ON enables Sheerpower's Debug System. DEBUG OFF disables the system.
The related function for the Sheerpower Debug System is _DEBUG. See Section 6.8.1 for information on the _DEBUG system function.
Some DEBUG features automatically switch DEBUG ON or OFF when they are executed. Others require that DEBUG be enabled. (See DEBUG ON/OFF)
Here is a list of Sheerpower's DEBUG System features that require DEBUG to be enabled:
*Unlike most languages, Sheerpower's debugging environment does not noticeably slow down program execution.
DEBUG ON |
The following example shows how the DEBUG ON statement is used inside an .SPSRC program to enable Sheerpower's debug system.
Example 2-17 DEBUG ON |
---|
debug on print '1', print '2', break print '3', print '4', print '5' end 1 2 break at main.0003 |
DEBUG ON is used to enable Sheerpower's debug system. Sheerpower's debug system helps locate problems in the way a program runs.
DEBUG must be enabled in order to use its features. When DEBUG is enabled, all of Sheerpower's debug features are available.
DEBUG ON can be issued in immediate mode (in the console window) or as a statement in a program.
If DEBUG ON is used as a statement in a program, Sheerpower enables DEBUG when it encounters the statement. DEBUG remains enabled until a DEBUG OFF command or statement is executed or until a DEBUG feature is executed which disables it.
DEBUG OFF |
debug off |
DEBUG OFF is used to disable Sheerpower's DEBUG system. Set DEBUG OFF when you have finished correcting your program.
DEBUG OFF can be issued in immediate mode or as a statement in a program. If DEBUG OFF is used in a program, Sheerpower disables DEBUG when it encounters the DEBUG OFF statement.
DEBUG will remain disabled until a DEBUG ON statement is executed, or until a DEBUG feature is executed which enables it.
Previous | Next | Contents | Index |