Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

2.3.3 LIST

FORMAT:


        LIST [routine_name, routine_name, ...] 

EXAMPLE:

To perform the following example, open the console window by clicking once on the console icon in SPDEV. Use the BUILD command to build one of the Sheerpower sample programs that come with the installation, set_icon.spsrc:


  build 'c:\sheerpower\samples\set_icon.spsrc' 

Then use the LIST command to display all the lines in the program.

Example 2-10 Listing Program Lines

build 'c:\sheerpower\samples\set_icon' 
Building c:\sheerpower\samples\set_icon.spsrc ... 
Lines processed: 11 (300/sec), code space used: 0KB 
   list
c:\sheerpower\samples\set_icon.spsrc  15-MAY-2015 15:13 
here$ = filespec$('@') 
set icon here$+"smiley.ico" 
print "Check out the taskbar icon... it's a smiley!" 
delay 
set icon here$+"frowny.ico" 
print "and now... it's changed to a frown!" 
end 

PURPOSE:

Use the LIST command to display all or part of your program source code.

DESCRIPTION:

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:

2.3.4 HALT Statement

FORMAT:


        HALT ['optional message text'] 

EXAMPLE:

To perform this next example, open SPDEV by clicking on the SPDEV shortcut icon on your desktop.

Create a new program file called halt_test.spsrc. See Section 1.2, Creating a New Program in Sheerpower for instructions.

Copy and paste the program code from the example below into the new file.

Example 2-11 HALT Statement

  do
    line input menu '"Calculator" = calc,"DOS Prompt" = dos,"EXIT"': ans$ 
    halt
    if  _exit  then  exit do
    select case ans$ 
    case 'CALC' 
      pass nowait: 'calc' 
    case 'DOS' 
      pass nowait: '$$' 
    end select
  loop
  end

Then run the program by clicking once on the Run icon in SPDEV. A menu will open.

Choose 'Calculator' from the menu. The following will appear inside the console window:


Halt at MAIN.4 
---------- 
>>>   MAIN.4                              halt 

Keep the console window open to continue with the next HALT statement example.

PURPOSE:

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. When the source code is compiled, SPDEV will inform you if there are any HALT statements found, but they are not treated as errors. 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.4.7, BREAK Statement.

DESCRIPTION:

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 in the console. Execution of the program can be continued with the GO command.

When a HALT statement is in the source code, Sheerpower will notify you in the Build tab window (at the bottom of SPDEV) at compile-time.


 Build of C:\sheerpower\samples\menu.spsrc 
 *** Note: This code contains HALT statements. 
 Lines processed: 12 (600/sec), code space used: 1KB 
 Clean build for C:\sheerpower\samples\menu.spsrc 

You can continue to run the sample program in the console window as follows:


Halt at MAIN.23 
---------- 
>>>   MAIN.23                         halt 
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.



2.3.4.1 Printing Additional Information with the HALT Statement

Additional information can be printed out with the HALT statement. The HALT statement works parallel to the PRINT statement. So anything valid in PRINT is also valid for HALT. For example:


  HALT 'optional useful information' 

More detailed information can also be printed out with the HALT statement. For example:


  x=123 
  y=456 
  HALT 'X=';x;' and Y=';y 

See Chapter 7, Printing and Displaying Data for all of the options that also work with the HALT statement.

2.3.5 SHOW ALL

FORMAT:


        SHOW ALL 

EXAMPLE:

Example 2-12 Using SHOW ALL in DEBUG

  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 all 

The results displayed in the console will be:


Halt at MAIN.5 
---------- 
>>>   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 
-- 
   show all 
Writing all debug information to... 
  C:\sheerpower\samples\show_all_debug.txt 
 
Done. 

PURPOSE:

SHOW ALL is normally used when debugging a program after it has been halted. It writes to a file information that helps to debug it.

DESCRIPTION:

SHOW ALL can be used inside your program as a statement or as a command in the console window (e.g. after a HALT statement executes). SHOW ALL generates a text file located in the same directory as the program being run. The text file name will be the same as the program name but with "_debug.txt" appended to the end. The debug file location will be displayed in the Console window. DEBUG ON does not need to be set in order to use SHOW ALL.

Example 2-13 Sample SHOW ALL Debug Text File

  Sheerpower  debug output on 05-JUN-2017 13:17:15 
 
  Filename: C:\SheerPower\samples\show_all.spsrc 
 
  --- 
  No error reported at Immediate 
 
  SYSTEXT--> The file exists. 
  --- 
 
  --- Call stack and recent routines --- 
  ---------- 
    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 
  -- 
  --- End of calls --- 
 
  --- Dump of variables --- 
 
  A = 200 
 
  X = 101 
 
  --- End of variables --- 
 
 
  --- Dump of open files --- 
  Last status: The file exists. (00000000) 
 
  channel: 000 status: 00000001 00000001  name: sys$output 
    open id: 1        flags : (t)input (t)output lock stream cancel 
    locked : 1        row   : 16       col   : 1       
    pagelen: 30       reclen: 2048     margin: 80       zone  : 20     
    cursize: 0        read  : 10       write : 31       blocks: 31     
    control: 70       rewind: 0        update: 0        delete: 0      
 
  --- End of open files --- 
 
  --- End of output --- 

2.3.6 SHOW CALLS

FORMAT:


        SHOW CALLS 


Previous Next Contents Index