SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

2.5.8 STEP

FORMAT:


        STEP [number] 

EXAMPLE:

Example 2-21 Using STEP in DEBUG system

run
1                   2                   break at main.0003 
 
 
step 2 
3                   4 

PURPOSE:

STEP is used to execute a specific number of program statements and then stop execution. That way, you can "step through" your program to find bugs.

DESCRIPTION:

STEP is used to step through a program---to execute a specified number of program statements. DEBUG must be ON for the STEP command to take effect. If DEBUG is not on and the STEP command is given, SheerPower ignores it. STEP must be given as a command. When the STEP command has been executed, SheerPower issues a BREAK and prints the break message. Issuing the STEP command without a number causes SheerPower to execute one program line.

Issuing the STEP command with a number causes SheerPower to execute the number of program lines specified. SheerPower begins executing program lines from the last line executed. It stops when the number of lines specified have been executed or when program execution ends.

You must start a program with RUN before you can use the STEP command.

2.6 SP4GL Console Window Keystrokes

In the console window the mouse can be used to select (highlight) text on the screen.

Below is a table containing the special keystrokes available when working in the console window.

Table 2-1 SP4GL Console Window Keystrokes
Keystroke Function Performed
ctrl/a selects all text (both on and off screen)
alt/b causes program execution to HALT
ctrl/c places selected text into the clipboard
ctrl/m places contents of message history into the clipboard
ctrl/t places contents of screen (including scroll buffers) into the clipboard


Chapter 3
Program Elements in SheerPower

This chapter describes the basic elements that make up a SheerPower program. It also describes the types of data used with SheerPower programs and how the data is processed.

3.1 Storing SheerPower Programs

SheerPower programs have a default extension of .SPSRC. It is recommended that you use this extension for all of your SheerPower programs. SheerPower source programs are saved as text files. You can edit SheerPower source programs with any text editor.

3.2 SheerPower Program Elements

A program is a series of instructions. These instructions describe how to manipulate data to produce a desired result. You determine what data the program will manipulate, how the program will manipulate it, and what the results of these manipulations will be.

When you create a program, you must use instructions that SheerPower understands. The SheerPower language provides these instructions. The language consists of statements. These statements are something like the words in this manual. You put them together in a meaningful order and SheerPower executes the program you write. Here is an example of a SheerPower program:

Example 3-1 SheerPower program example

  input 'Please enter your name': name$ 
  print 'Hello, '; name$ 
  print 'Today is '; day$ 
  print name$; ', have a good '; day$ 
  end

The INPUT statement tells SheerPower to ask for a name. The PRINT statements tell SheerPower to print the information. END tells SheerPower it has reached the physical end of the program.

3.2.1 PROGRAM

FORMAT:


        PROGRAM prog_name 

EXAMPLE:

Example 3-2 Program statement

  program display_name 
  input 'Please enter your name': name$ 
  print 'Hello, '; name$ 
  end

PURPOSE:

The PROGRAM statement is used to name your program.

DESCRIPTION:

PROGRAM is used to name programs. prog_name is the program name. The program name must meet the following specifications for variable names:

With SheerPower, when you execute this program, it will look like this:


Please enter your name? Tester  <---type your name here then press [Enter]
Hello, Tester 

3.2.2 SheerPower Reserved Words

When you run the next program example, you will notice that the day is not asked for. DAY$ is a reserved word that SheerPower uses for storing the day. There are several other reserved words that SheerPower uses. You can refer to Appendix B, Reserved Words to see a complete list of the reserved words.

Example 3-3 SheerPower Reserved Words

  input 'Please enter your name': name$ 
  print 'Hello, '; name$ 
  print 'Today is '; day$ 
  print name$; ', have a good '; day$ 
  end
 
 
 
Please enter your name? Julian 
Hello, Julian 
Today is Tuesday 
Julian, have a good Tuesday 

3.3 SheerPower Program Structure

SheerPower programs are modular in structure. Every program can be divided into program units. The main unit is the main body of the program. This unit begins with the first program line and ends with the END statement.


    first program line --   input 'Please enter your name': name$ 
                            print 'Hello, '; name$ 
                            print 'Today is '; day$ 
                            print name$; ', have a good '; day$ 
         end statement --   end

3.3.1 END

FORMAT:


        END 

EXAMPLE:

Example 3-4 END statement

  input 'Please enter your name': name$ 
  print 'Hello, '; name$ 
  end
 
 
Please enter your name? John 
Hello, John 

PURPOSE:

The END statement is used to mark the physical end of a program. It should be the last line of your program.

DESCRIPTION:

The END statement marks the end of a program. When SheerPower executes the END statement, it writes all active output buffers and closes all files in the current program.

3.3.2 STOP

FORMAT:


       STOP 

EXAMPLE:

Example 3-5 STOP statement

  input 'Please enter your name': name$ 
  input 'How old are you': age 
  if  age < 1  then
    print 'Not a valid age' 
    stop
  end if
  print name$; ' is'; age 
  end
 
 
Please enter your name? Ted 
How old are you? .5 
Not a valid age 

PURPOSE:

STOP is used to terminate program execution where you do not want to mark the physical end of your program.

DESCRIPTION:

STOP behaves exactly as the END statement does. However, STOP does not mark the end of a program.

The STOP statement does not have to be the last physical line in a program. If there are subprograms, functions, etc., they can physically follow the STOP statement.

The STOP statement:

3.4 ROUTINE/END ROUTINE

FORMAT:


        [PRIVATE] ROUTINE routine_name [: private varname, ...] 
           --- 
           --- block of code 
           --- [REPEAT ROUTINE] 
           --- [EXIT ROUTINE] 
        END ROUTINE          

EXAMPLE:

Example 3-6 ROUTINE/END ROUTINE statements

  get_username 
  stop
 
  routine get_username 
    input prompt 'Username: ': uname$ 
    if  _back or _exit  then exit routine
  end routine
 
 
Username: Tester 

PURPOSE:

ROUTINES are block-structured subroutines. They provide a convenient way to name a block of code. By default, all variables in the main program are available inside the routine. To specify private variables that are not part of the main program use the PRIVATE option. To cause all variables inside of a routine to be treated as private, make the routine a PRIVATE ROUTINE.

Note

See Appendix M, SheerPower and Program Segmentation for more on routines and private routines in SheerPower.


Previous Next Contents Index