| Previous | Contents | Index |
RUN ['file_spec']
|
The following example assumes that you have a SheerPower program file called 'sample_program.spsrc' in your SheerPower folder. This sample program was created in a previous section. See Section 2.2, Creating a Sample Program. |
To perform this example, open sample_program.spsrc inside SheerPower Rapid Development Environment. Click once on the Run icon in the toolbar to run the program. A menu will appear on your screen with three choices. Choose 'Exit', and the console window will appear.
Inside the console window, type 'RUN', and press [Enter]. The RUN command will cause the program to execute again, and the resulting menu created will appear.
| Example 2-11 RUN command |
|---|
run c:\sheerpower\sample_program.spsrc 14-Jul-2001 15:30 |
The RUN command is used to execute a program after it has been written inside SPDEV. This way you can remain inside the SP4GL Console Window and run your program after you experiment with elements of your program.
The RUN command can be used:
The RUN command executes programs. RUN with no file specification runs the current program.
When SheerPower executes the RUN command, SheerPower displays a header with the program name, current date and time. SheerPower then executes the program.
A file specification can be given with the RUN command. If a file specification is provided, SheerPower searches for the file, loads it, and then runs it. If no file type is given, SheerPower will use the default file type .SPSRC.
| Example 2-12 RUN command with file specification |
|---|
run 'sample_program' c:\sheerpower\sample_program.spsrc 14-Jul-2001 15:30 |
Choose 'Exit' from the menu to complete running the program, then close the SP4GL Console Window.
If you are running a program that is not stored inside the SheerPower folder, you must specify the path (location) of the program.
LIST [routine_name, routine_name, ...]
|
To perform the following example, open the console window by clicking once on the SP4GL Console Window icon in SPDEV. Use the BUILD command to build the sample program (sample_program.spsrc). Then use the LIST command to display all the lines in the program.
| Example 2-13 Listing program lines |
|---|
build 'sample_program.spsrc'
Building c:\sheerpower\sample_program.spsrc ...
Lines compiled: 11 (33000/min), code: 1KB
list
c:\sheerpower\sample_program.spsrc 06-Jul-2001 16:29
do
line input menu '"Calculator" = calc,"DOS Prompt" = dos,"EXIT"': ans$
if _exit then exit do
select case ans$
case 'CALC'
pass nowait: 'calc'
case 'DOS'
pass nowait: '$$'
end select
loop
|
Use the LIST command to display all or part of your program source code.
LIST displays lines from the current program. The listing includes a header with the program name, current date and time. LIST by itself lists the entire program, including routine headers and comment lines.
Specific sections of a program can be listed by referencing the program's routines. You can also list combinations of routines. For example:
| list do_input | lists the lines of code under the routine "do_input" |
| list date_routine | lists the lines in the "date_routine" routine |
| list do_input, date_routine | lists the lines from both routines |
If a routine is specified which does not exist, nothing is listed.
You can use the LIST command:
HALT
|
Open SPDEV by clicking on the SPDEV shortcut icon on your desktop.
Open the sample program file sample_program.spsrc
inside SPDEV by clicking on the Open icon inside the
SPDEV toolbar.
Insert the HALT statement into the sample_program.spsrc source code as shown below.
Then run the program by clicking once on the Run icon
in SPDEV.
| Example 2-14 HALT statement |
|---|
do
line input menu '"Calculator" = calc,"DOS Prompt" = dos,"EXIT"': ans$
halt //<--- insert HALT statement here
if _exit then exit do
select case ans$
case 'CALC'
pass nowait: 'calc'
case 'DOS'
pass nowait: '$$'
end select
loop
|
Choose 'Calculator' from the menu. The following will appear inside the SP4GL Console Window:
Halt at main.0003 |
Keep the SP4GL Console Window open to continue with the next HALT statement example.
HALT is used to interrupt program execution, check values, and then continue execution.
The HALT statement must be inserted inside the source code before running the program. The HALT statement works the same way as the BREAK statement except that it always interrupts program execution. The BREAK statement will only interrupt program execution while DEBUG is ON. For a detailed explanation of the BREAK statement, please see Section 2.5.7, BREAK Statement.
HALT interrupts program execution, but it does not close any files, nor does it write the active output buffer. Once halted, the user can then check values, enter debug commands or any SheerPower statements and expressions. Execution can be continued with the GO command.
You can continue to run the sample program in the console window as follows:
Halt at main.0003 print ans$ <--- type this line in and press [Enter] CALC go<--- type in 'GO' and press [Enter] |
The calculator program will appear when your program resumes execution. To exit the program, choose 'Exit' in the menu, then close the console window.
|
|
GO
|
Copy/Paste or type the following example into a new file inside SPDEV.
Name it 'test.spsrc'.
| Example 2-15 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 |
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, 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.
Type in the PRINT command as shown below inside the console window, 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 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.)
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.
| Previous | Next | Contents | Index |