SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

3.7.3 The (//) with Line Continuation

The double-forward slash can be used after an ampersand to document continued lines. When a line is continued with an ampersand, any comments must follow the ampersand. For example:

Example 3-23 Comments with line continuation

  input a$ 
  if  a$ = ''  then  print a$; &     // here is the trailing
      ' is OK.'                      // comment text
  end

3.8 Debug Comments in SPDEV

Code that is inserted into a program for the sole purpose of debugging the program should be marked with a debug comment. SheerPower can automatically create a debug comment line for you with a special keystroke.

The GOLD/C keystroke is mapped to create a debug comment line. In SPDEV, a GOLD key is a special key that allows you to utilize other keys for different purposes. The GOLD key is either the [Esc] (Escape) key or the [NumLock] (Numbers Lock) key. See Appendix F, Keystrokes for SheerPower Rapid Development Environment for more special SheerPower Rapid Development Environment keystrokes.

To perform a GOLD/C keystroke, place the cursor where you want the debug comment line created. Press once on the [Esc] key or the [NumLock] key. Let go and look in the bottom right hand corner of the SPDEV window. SheerPower tells you if your GOLD key is activated by highlighting a small square in the bottom frame in black, with gold letters that say 'Gol'. Now you can press the [C] key, and a small dialog box will appear asking you for your initials. Leaving your initials will allow future programmers (as well as yourself) to know who inserted this line of debug code. Enter your initials, and click on 'OK'.

Example 3-24 Debug comments

!++ debug sw June 08, 2001 

The '!++' at the beginning of every line of debug comment makes it very easy to perform a search and find all lines containing debug code.

3.9 Program and Compile Directives

The following sections describe the directives that are available for use in your programs. These directives are invoked when the compiler builds a program and/or when a program is compiled.

3.9.1 %COMPILE

FORMAT:


        %COMPILE 'quoted_text' 

EXAMPLE:

Example 3-25 %COMPILE program directive

  print 'This is a test program.' 
  %compile 'Text that you want to be seen inside the SPRUN file...' 
  %compile 'Up to 100 lines of text can be seen here!' 
  end

DESCRIPTION:

Using the DEPLOY feature you can make portable runnable applications (.SPRUN files). These files are plain text, and can be password protected.

SPRUN files allow you to distribute SheerPower programs without your source code being seen.

An SPRUN file can be easily copy/pasted, emailed or embedded into a website. This allows for simple distribution of an application.

The %compile text is truncated at 72 characters. There can be up to 100 %compile text lines in a program.

Once the text is inside the SPRUN file, if it is altered in any way the SPRUN file will not run! This is a good place to put copyright notices and license agreements, etc.

3.9.2 %MESSAGE

FORMAT:


        %MESSAGE 'quoted_text' 

EXAMPLE:

Example 3-26 %MESSAGE program directive

  %message 'Including HELP module' 
  %include 'sptools:help' 
  end

DESCRIPTION:

This compiler directive displays a message, quoted_text, on the message line. The message is displayed when a program is built into a workspace or compiled.

3.9.3 %MESSAGE ERROR

FORMAT:


        %MESSAGE ERROR: 'quoted_text' 

EXAMPLE:

Example 3-27 %MESSAGE ERROR program directive

  %message error: 'Using experimental HELP module' 
  %include 'sptools:help' 
  end

DESCRIPTION:

This compiler directive makes an alert sound and displays the message when a program is compiled.

3.9.4 %INCLUDE

FORMAT:


        %INCLUDE 'file_spec' 

EXAMPLE:

Example 3-28 %INCLUDE program directive

   %include 'sptools:example' 

PURPOSE:

%INCLUDE allows you to put common subroutines into a separate file to be shared among applications.

DESCRIPTION:

%INCLUDE includes a source code into the current SheerPower program. The default extension for the included file is .SPINC.

3.9.5 %INCLUDE CONDITIONAL

FORMAT:


        %include conditional: 'file_spec' 

DESCRIPTION:

If the file to be included does not exist, no error is generated. This allows programs to conditionally include modules.

%INCLUDE CONDITIONAL includes a source code file into the current SheerPower program if the file to be included is found. The default extension for the included file is .SPINC.


Chapter 4
Data Types in SheerPower

Programs manipulate data. The data can be numeric or textual, but the data must be presented according to the rules of the SheerPower language.

4.1 Data Types

SheerPower accepts three basic types of data:

  1. integer numbers
  2. real numbers
  3. string (textual) data

The following sections describe each of the three types of data.

4.1.1 Integers

An integer number is a whole number with no fractional part. The following are examples of integers:


                +5%       894%       -369004% 
Integers can be positive or negative. Integer constants can end with a trailing percent sign (%). About integers:

4.1.2 Real Numbers

A real number can have a fractional part. The following are real constants:


              5.4             894.0              -369004 
Real numbers can be positive or negative. Any number that is not designated as an integer or a string is treated as a real number.

A real number without a decimal point is called an ambiguous constant. About real numbers:

Here is an example of SheerPower exact math:

Example 4-1 SheerPower Exact Math

  x = 0 
  for i = 1 to 10000 
    x = x + .01 
  next i 
  if  x = 100.00  then print 'It is right.' 
   
   
It is right. 

If you try this example in another programming language (Visual Basic or C++ for example), you will not get the correct answer. Here is another example:

Example 4-2 SheerPower Exact Math

  print 123456789.012345 * 87654321.123456789 
   
   
10821521028958940.344459595060205 

4.1.3 String Data

String data consists of text. Text can consist of any characters. All of the following are valid string constants:

Example 4-3 String data

    'Hello, Fred.' 
 
    'Account number (##-####)' 
 
    '65' 

About string data:


Previous Next Contents Index