Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index


 Build of C:\SheerPower\samples\check_power.spsrc 
file: C:\SheerPower\samples\check_power.spsrc 
    (line 11, column 1):  Unrecognized statement 
    (line 36, column 4):  Unrecognized SET/ASK keyword 
    Unrecognized statement at MAIN.11 
    Unrecognized SET/ASK keyword at MAIN.36 
 Lines processed: 118 (11800/sec), code space used: 3KB 
 Errors (4) in C:\SheerPower\samples\check_power.spsrc 

When routines are detected in the code and the error occurred inside of a routine, the location displayed for the error will start with the routine name and the line number starting from the beginning of the routine. For example, GET_AC_STATE.4 means the error occurred on the 4th line down from the definition of the routine called GET_AC_STATE.


 Build of C:\SheerPower\samples\check_power.spsrc 
file: C:\SheerPower\samples\check_power.spsrc 
    (line 102, column 4):  Syntax error 
    Syntax error at GET_AC_STATE.4 
 Lines processed: 118 (5900/sec), code space used: 3KB 
 Errors (2) in C:\SheerPower\samples\check_power.spsrc 

For a list of Sheerpower error and exception messages, see Appendix C, Sheerpower 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 from your current location in the file to help navigate to the location of the error. For more specialized programming keystrokes in SPDEV, see Appendix F, Keystrokes for Sheerpower Rapid Development Environment.

1.2.3 Running a Sheerpower Program

At any time you can RUN your main source program. To run a program in Sheerpower Rapid Development Environment, click on the Run icon in the toolbar---the running man.

If there are no Sheerpower program files open in SPDEV, the Run icon will be disabled.

You can also run a Sheerpower program (.SPSRC and .SPRUN) by double-clicking on the file name.

When a program is run in SPDEV you will know immediately if there are any compile errors in your code; they will appear inside the Results Window (at the bottom of SPDEV) in the Build tab. These program compile results are also displayed you Validate or Deploy a program.

Run MENU.SPSRC Program

With the sample menu.spsrc program open in SPDEV, run it by clicking on the Run icon in the SPDEV toolbar. The following menu will appear:

Temp Folders and Security in Sheerpower

As a security feature, Sheerpower programs cannot be run if they are inside of any temporary folder. This prevents users from accidently running malicious code written in Sheerpower that a hacker might place into an email or webpage.

1.3 Deploying a Program in Sheerpower

Once you have written a Sheerpower program you can DEPLOY it by clicking on the Deploy icon in the toolbar.

If there are no Sheerpower program files open in SPDEV, the Deploy icon will be disabled (greyed out).

The DEPLOY feature creates a .SPRUN file (i.e., menu.sprun). SPRUN files are useful in that:

Deploying your main source code will display immediately if there are any compile errors in your code. Any errors will appear inside the bottom window frame of SPDEV, and the .SPRUN program file will not be created. If there are no compile errors, SPDEV displays that the program was a clean build and the .SPRUN file is created.

Deployed applications can include the %COMPILE directive. The %COMPILE directive allows you to enter in up to 100 lines of text inside the .SPRUN file. This text cannot be altered or the application will not run. See Section 3.9.1,%COMPILE for details.

Deploy the menu.spsrc Program

With the sample menu.spsrc program file open, click on the DEPLOY icon in the SPDEV toolbar.

This will bring up the Enter License Key dialog box. Sheerpower comes with an unlimited-use license key by default - it is free to use for everyone. Keep this default license key information and click on [OK] to proceed with the deployment of the program.

The Deployment Properties dialog box will appear. You can now enter in an optional password to protect this program file. If you assign a password to the program file, only users who have the password will be able to run it.

If you do not want to be prompted to enter in a password each time you click on the Deploy button, place a check in the box beside Don't show this dialog again. To simply deploy the program without assigning a password, just leave the password field blank.

Click on the [OK] button to deploy the program.

You will now see in the bottom frame of SPDEV that deploying the program compiled it. It displays the number of lines of code, file size, and if it was a clean build or if there were any compile errors.

Look inside your Sheerpower folder (c:\sheerpower is the default location). A new file with the name menu.sprun has been created.

You can distribute this .SPRUN program file without the recipients ever being able to see the source code.

1.3.1 Saving a Program in Sheerpower

To SAVE your program in SPDEV, click once on the Save icon in the SPDEV toolbar---the floppy disk icon.

If you have multiple files open in SPDEV that you wish to save, click on the Save All icon in the SPDEV toolbar---the icon with three floppy discs together.

You can also click on File in the SPDEV toolbar and select Save from the drop down menu. In addition, each time you VALIDATE, RUN or DEPLOY a program file in SPDEV, the file is automatically saved.

1.3.2 File Backup Versions

SPDEV has a built-in file backup feature that allows you to keep up to the last 10 versions of any file edited in SPDEV. The default number of versions to save is 3. Each time you save your file in SPDEV for the first time, the original version is saved with a version number behind it:


  myprogram.spsrc   <-- current version 
  myprogram.spsrc-1 <-- last saved version 
  myprogram.spsrc-2 <-- 2nd last saved version 
  myprogram.spsrc-3 <-- 3rd last saved version 

Another version of the file will not be saved until the next time you open the file again in SPDEV.

To choose the number of backup file versions for SPDEV to automatically save, click on Options in the SPDEV toolbar. Select Change System Settings, then enter in the Number of Backup File Versions to save (0-10). To disable this feature, uncheck the box beside "Create File Versions" in the System Settings screen.

1.3.3 Purge Old Backup Files

To delete any unwanted SPDEV backup files, click on the Purge icon in the SPDEV toolbar. The Purge Versions dialog box will appear.

Select the folder or files that you wish to purge in the Look in: field. You can choose to purge either Sheerpower (.spsrc) files or all file types in the drop-down list at the bottom of the dialog box.

A Purge Subfolders option is also available inside the Purge Versions dialogbox. Place a check inside the checkbox if you want to include purging the backup files inside the subfolders of the selected directory.

Once you have selected the folder or files to purge, and the file type, click on the Purge Now button. You will be prompted to confirm that you want to purge the files in the selected path. Click on the OK button. The Purge Results window will appear containing a list of all the backup files purged. If no backup files were in the folder then nothing will be purged.

The option to purge only the backup versions of the current file you are working in is also available. Click on File in the SPDEV toolbar, then select Purge Current File.

1.4 Documentation Program Examples

In the program examples, keywords in Sheerpower statements and commands are in bold, and information you (the user) supply is in regular text. The program examples are designed so that they can be typed, or copied and pasted into SPDEV and run. Below each example, the results are shown.

Sheerpower Coding Standards

All examples shown in this manual conform to Sheerpower coding standards. This includes all code being typed in lower-case and with proper line indentation. For more information on coding standards in Sheerpower, please refer to the Sheerpower Coding Standards manual and Appendix A, Coding Principles and Standards.

To assist, Sheerpower automatically indents the code according to the statement last typed in.

*The double quote (") can be used in place of the single quote (') as long as they are paired.

Try out the following examples for yourself in SPDEV:

Example 1-2 Menu Program Example

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

Example 1-3 Display and Update Database Program Example

// Display and update Customer information 
 
open structure cust: name 'sheerpower:\samples\customer', access outin
 
print "Customer Record List" 
print "====================" 
print
extract structure cust 
end extract
for each cust 
  print cust(custnbr), cust(name), cust(phone) //display customer info 
next cust 
 
do
  print
  print "Update Customer Record" 
  print "======================" 
  print
  line input 'Customer number to update', default '12513': cust$ 
  if _exit or _back or cust$ = '' then exit do //get out if nothing to do 
  set structure cust, field custnbr: key cust$  // do the search 
  if _extracted = 0 then
    message error: 'Cannot find '; cust$ 
    repeat do
  end if
  print cust(custnbr), cust(name) 
  line input 'New name', default cust(name): newname$ 
  if _exit or _back then repeat do
  cust(name) = newname$  // update the name 
  print
  line input 'New phone number', default cust(phone): newphone$ 
  if _exit or _back then repeat do
  cust(phone) = newphone$  // update the phone number 
  print
  print '**Customer Record Updated**' 
  print
loop
end


Previous Next Contents Index