| Previous | Contents | Index |
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
|
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.
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.
%COMPILE 'quoted_text'
|
| 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 |
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.
%MESSAGE 'quoted_text'
|
| Example 3-26 %MESSAGE program directive |
|---|
%message 'Including HELP module' %include 'sptools:help' end |
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.
%MESSAGE ERROR: 'quoted_text'
|
| Example 3-27 %MESSAGE ERROR program directive |
|---|
%message error: 'Using experimental HELP module' %include 'sptools:help' end |
This compiler directive makes an alert sound and displays the message when a program is compiled.
%INCLUDE 'file_spec'
|
| Example 3-28 %INCLUDE program directive |
|---|
%include 'sptools:example' |
%INCLUDE allows you to put common subroutines into a separate file to be shared among applications.
%INCLUDE includes a source code into the current SheerPower program. The default extension for the included file is .SPINC.
%include conditional: 'file_spec'
|
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.
Programs manipulate data. The data can be numeric or textual, but the data must be presented according to the rules of the SheerPower language.
SheerPower accepts three basic types of data:
The following sections describe each of the three types of data.
An integer number is a whole number with no fractional part. The following are examples of integers:
+5% 894% -369004%
|
A real number can have a fractional part. The following are real constants:
5.4 894.0 -369004
|
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 |
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 |