SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

2.1.2.1 Command Completion in SheerPower

In the SP4GL Console Window, enter part of a command and then press the [Tab] key. SheerPower will then supply the full name of the command. If the command is ambiguous, a selection menu of all valid choices will appear.

In the following example, SheerPower completes "so" to form the command "sort".

Open the SP4GL Console Window by clicking on the SP4GL Console Window icon in the SPDEV toolbar. At the flashing cursor in the console window, type in the word "so". Press the [Tab] key and you will see "so" completed to be the command "sort".

Example 2-5 Command completion

so[Tab]  <--- your entry, press [Tab]
  
sort  <--- SheerPower supplies 

Next, type the word "in", then press the [Tab] key. In this example, "in" is ambiguous, so SheerPower provides a menu of choices:

Example 2-6 Command completion

in[Tab]                                    +--Choices---+                 
                                           |  include   | 
                                           |  inf       | 
                                           |  input     | 
                                           +------------+ 

Command Completion in the SP4GL Console Window and SPDEV

Command completion will also work in SPDEV. However, the SP4GL Console Window and SPDEV use different methods to perform command completion. Therefore, they will not always agree on which command or statement you are wanting to complete.

2.1.2.2 Spelling Correction of Commands in SheerPower

The [Tab] key can be used to correct misspelled commands in the console window, as well as misspelled statements in SPDEV. Just position the cursor on the misspelled word and press the [Tab] key. The word will be replaced with its correct spelling. In the example below, the misspelled command SET STRCTRE is changed instantly to the correct command spelling when the [Tab] key is pressed.

To perform the following example, open the SP4GL Console Window by clicking on the SP4GL Console Window icon in the SPDEV toolbar. Inside the console window, type:

Example 2-7 Spelling correction

set strctre[Tab] //<-- press [Tab]
set structure 

2.1.2.3 Expanding Abbreviations

SheerPower uses abbreviations for a number of commands. The [Tab] key can be used with any of the specific abbreviations to expand the abbreviations. To use this feature, enter an abbreviation and then press the [Tab] key. The period '.' must be used after each abbreviation. The current abbreviations that can be used are:

os. open structure
es. extract structure
ee. end extract
in. include
ex. exclude
fe. for each
e. edit
l. list
p. print
pu. print using
ss. set structure
pa. print at
li. line input
pc. print #
oc. open #
pe. print _extracted
lm. line input menu
ls. line input screen

2.2 Creating a Sample Program

Open a new file inside SheerPower Rapid Development Environment by clicking once on the New icon in the toolbar---a white paper with one corner folded.

Name the new file "sample_program". Press the Save button inside the New File dialog box. The file type .SPSRC will automatically be added when the Save button is pressed.

The Get Program Info dialogbox will appear, prompting you for your name, company name and program name. This will create a Program Template inside the new program file. For the purpose of this documentation, press the [Cancel] button. This will create an empty program file, with no program template.

See Section I.2, Program Template for more on creating a program template within a .SPSRC file. If you do create a program template in your new file, copy and paste or type the following program into the new file below the Main Logic Area above the word stop.

Otherwise, copy and paste or type the following program into the new program file:

Example 2-8 Program example

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

You can run this program by clicking once on the Run icon---the running man. The result of the program is shown below:

Choose 'EXIT' in the menu to complete running the program, then close the console window by typing 'exit' or clicking on the 'X' in the top right corner of the window.

This example will be used throughout the next few sections of this chapter.

Notice that after you completed running the sample program the following information appears in the results window (at the bottom of SPDEV) inside the Build tab:


Build of c:\sheerpower\sample_program.spsrc 
Lines compiled: 11 (33000/min), code: 1KB 
Clean build for c:\sheerpower\sample_program.spsrc 

If you had any compile errors in your source code, they will be listed here along with the location of the error, and the type of error.

2.3 Errors and Exceptions

In the console window, errors are returned either immediately after typing a syntactically incorrect line, or when the RUN command is given and your program is syntactically incorrect.

Errors happen when the program is compiling. Exceptions happen as the program is running.

In the case that the error happens outside of a routine (in the main logic area) the location of the error will always start with "main" followed by a period. Following the period is the source code line number.

I.E., main.0006 means the error occurred in the 6th line from the top of the file.

I.E., do_totals.0003 means the error occurred in 3 lines from the definition of the routine called do_totals.

For a list of the different SheerPower error and exception messages, see Appendix C, SheerPower's Error and Exception Messages.

In SPDEV the Alt + UP or DOWN arrow key can be used to move up or down a specific number of lines in your file. For more specialized programming keystrokes in SPDEV, see Appendix F, Keystrokes for SheerPower Rapid Development Environment.

2.4 Using Commands in SP4GL Console Window

2.4.1 BUILD

FORMAT:


        [BUILD 'program_name'] 

EXAMPLE:

Important note on the following example

The following example assumes that you have a SheerPower program file called 'sample_program' in your SheerPower folder. This sample program was created in the previous section. See Section 2.2, Creating a Sample Program.

To run this example, open the console window by clicking once on the SP4GL Console Window icon in the SPDEV toolbar. Type in the example as shown below inside the SP4GL Console Window, then press [Enter].

Example 2-9 BUILD command in SP4GL Console Window

build 'sample_program'   //<--- type this line in and press [Enter]
  
Building c:\sheerpower\sample_program.spsrc ... 
Lines compiled: 11 (33000/min), code: 1KB 

PURPOSE:

Use the BUILD command to build a program in the SP4GL Console Window. Any build errors will be listed when you perform the BUILD command.

DESCRIPTION:

The BUILD command used in the console window defaults to the SheerPower folder. When building a program that is not stored inside the SheerPower folder, the path (location) of the program must be specified. See the following example:

Example 2-10 BUILD command in SP4GL Console Window with file specification

build 'c:\windows\desktop\sample_program.spsrc' 
    
    
Building c:\windows\desktop\sample_program.spsrc ... 
Lines compiled: 11 (33000/min), code: 1KB    


Previous Next Contents Index