| Previous | Contents | Index |
LIST STATS is used to display the statistics recorded by the STATISTICS feature.
LIST STATS lists each program line along with the number of times the line was executed and the execution time of each line.
The far left column lists the number of times each statement was executed. The next column gives the time each statement took to execute. The time is given in seconds and fractions of a second. (0.01 means the program line was executed in one-one hundredth of a second.) The last column lists the program itself. STATS must be ON for LIST STATS to be executed.
All the options available with the "LIST" statement are also available with LIST STATS. (See Section 2.4.3, LIST for more information.)
BREAK
|
| Example 2-21 Using BREAK in DEBUG system |
|---|
debug on print '1', print '2', break print '3', print '4', print '5' end 1 2 break at main.0003 |
BREAK is used to stop program execution when DEBUG is ON. For instance, you might use BREAK to stop the program if a variable is assigned a wrong value.
The BREAK statement can be used anywhere in a program. The BREAK statement will not take effect unless DEBUG is turned on. If DEBUG is off, SheerPower ignores any BREAK statements.
The HALT statement works the same way as the BREAK statement (see Section 2.4.4, HALT Statement) except that it always interrupts program execution.
When SheerPower executes a BREAK statement, it interrupts program execution and prints a BREAK message. The BREAK message tells what line the break occurred in. Program execution can be continued with the GO or STEP commands.
STEP [number]
|
| Example 2-22 Using STEP in DEBUG system |
|---|
run 1 2 break at main.0003 step 2 3 4 |
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.
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.
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.
| 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 |
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.
PROGRAM prog_name
|
| Example 3-2 Program statement |
|---|
program display_name input 'Please enter your name': name$ print 'Hello, '; name$ end |
The PROGRAM statement is used to name your program.
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
|
END
|
| Example 3-4 END statement |
|---|
input 'Please enter your name': name$ print 'Hello, '; name$ end Please enter your name? John Hello, John |
The END statement is used to mark the physical end of a program. It should be the last line of your program.
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.
STOP
|
| Previous | Next | Contents | Index |