SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

2.4.6 GO

FORMAT:


        GO 

EXAMPLE:

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 
-- 

PURPOSE:

GO is used to continue a program after it has been interrupted.

DESCRIPTION:

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 
-- 
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 

2.5 Debug Facilities

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.

DEBUG ON/OFF

2.5.1 DEBUG ON

FORMAT:


        DEBUG ON 

The following example shows how the DEBUG ON statement is used inside an .SPSRC program to enable SheerPower's debug facility.

EXAMPLE:

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 

PURPOSE:

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.

DESCRIPTION:

DEBUG ON can be issued in immediate mode 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.

2.5.2 DEBUG OFF

FORMAT:


        DEBUG OFF 

EXAMPLE:


        debug off 

PURPOSE:

DEBUG OFF is used to disable SheerPower's DEBUG system. Set DEBUG OFF when you have finished correcting your program.

DESCRIPTION:

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.

2.5.3 TRACING APPLICATION LOGIC FLOW

FORMAT:


        TRACE ON|OFF 

EXAMPLE:

Example 2-18 TRACE ON/OFF

debug on
trace on
do_totals 
trace off
stop
 
routine do_totals 
  print "Doing totals..." 
end routine
 
 
Doing totals... 

PURPOSE:

In complex applications, there is often a need to follow an application's program flow in order to figure out how the application works. This is also useful when debugging logic errors in an application.

DESCRIPTION:

TRACING is used to follow an application's logic flow. As each statement is executed, the trace window will display the label and line number and source line being executed.

To turn off tracing, just close the trace window. TRACE OFF will stop tracing, but leave the trace window open.

You can copy select or all of the text inside the trace window by highlighting the text with your mouse (CTRL/A will select all) and using CTRL/C to copy it.

In the console window toolbar, you can use the Trace icon to toggle the trace feature on or off.

The STATISTICS Features

STATISTICS records information on a program's execution. It records the time each program line takes to execute and the number of times the line is executed. The word "STATISTICS" can be abbreviated to "STATS" (STATS ON, STATS OFF, LIST STATS). This abbreviation will be used frequently in this Guide.

2.5.4 STATS ON

FORMAT:


        STATS ON 

EXAMPLE:

Example 2-19 STATS ON

  debug on
  stats on
  dim name$(5) 
  for i = 1 to 5 
    input 'Please enter your name': name$(i) 
    if  _exit  then exit for
    print 'Hello, '; name$(i); '!' 
  next i 
  end
  
  
Please enter your name? Tester 
Hello, Tester! 
Please enter your name? exit   <---- type in 'exit' and press [Enter]

PURPOSE:

STATS ON is used to turn on the statistics feature, which stores the execution time and count for each program line. Use STATS to tell if statements are being executed the correct number of times and which parts of a program are taking the most time. STATS is especially useful for speeding up a program's execution time.

DESCRIPTION:

STATS ON enables SheerPower's statistics feature. SheerPower begins recording statistics when program execution begins. The statistics feature remains enabled until the STATS OFF statement is executed.

STATS ON can be executed in immediate mode or in a program. If STATS ON is executed in immediate mode, DEBUG is automatically switched on. If STATS ON is executed in a program, and DEBUG is off, SheerPower ignores the statement. When STATS ON is executed, any statistics previously recorded are lost.

2.5.5 STATS OFF

FORMAT:


        STATS OFF 

EXAMPLE:


        stats off 

PURPOSE:

STATS OFF is used to turn off the statistics feature.

DESCRIPTION:

STATS OFF turns off SheerPower's statistics feature. STATS OFF can be executed in immediate mode or in a program. If STATS OFF is executed in a program and DEBUG is off, SheerPower ignores the statement. STATS OFF leaves DEBUG on.

2.5.6 LIST STATS

FORMAT:


        LIST STATS [: routine_name, routine_name ,....] 

EXAMPLE:

Example 2-20 Listing statistics in DEBUG system

  debug on
  stats on
  dim name$(5) 
  for i = 1 to 5 
    input 'Please enter your name': name$(i) 
    if  _exit  then exit for
    print 'Hello, '; name$(i); '!' 
  next i 
  end
  
  
Please enter your name? Tester <--- type name in, press [Enter]
Hello, Tester! 
Please enter your name? Tester <--- type name in, press [Enter]
Hello, Tester! 
Please enter your name? Tester <--- type name in, press [Enter]
Hello, Tester! 
Please enter your name? Tester <--- type name in, press [Enter]
Hello, Tester! 
Please enter your name? exit   <--- type in 'exit', press [Enter]

Once you have run the program with the STATS ON, you can use the LIST STATS feature. Type in LIST STATS at the prompt, and the console window will display the file name, the date and time of day, and the statistics for each line in the program.


list stats
c:\sheerpower\list_stats.spsrc  04-SEP-2003 12:46 
                          debug on 
1        0.00      stats on 
1        0.00      dim name$(5) 
1        0.00      for i = 1 to 5 
5        20.55       input 'Please enter your name': name$(i) 
5        0.00        if  _exit  then exit for 
4        0.00        print 'Hello, '; name$(i); '!' 
4        0.00      next i 
1        0.00      end 
          
          
    stats off  <--- type in to turn off STATS 
    debug off  <--- type in to turn off DEBUG       


Previous Next Contents Index