Previous | Contents | Index |
Example 1-4 Expression Evaluator Program Example |
---|
// Evaluate an expression // Type in the expression and press [enter] // // The expression can by very complex. For example: // ((34-324)/14)*10.1234 declare dynamic answer formtop$= '<sheerpower persist>' + '<title>Expression Evaluator</title>' + '<form><h2>Enter an expression</h2>' + 'For example--> ((344574647-324978)/154574)*13350.1234' + '<input name=expr submit>' + '<p>' formend$ = '<p><input type=submit name=submit value="Submit">' + '<input type=submit name=exit value="Exit"></form>' form$ = formtop$ + formend$ do input dialogbox form$: response$ if _exit then exit do z0$ = element$(response$, 1, chr$(26)) // get the first field expr$ = element$(z0$, 2, '=') // get the data for the first field if expr$ = '' then repeat do when exception in answer = eval(expr$) use answer = extext$ end when if dtype(answer) <> 1 then answer = str$(answer) form$ = formtop$ + '<h2><font color=green>' + expr$ + '</font></h2>' + '<h3>' + answer + '</h3>' + formend$ loop end |
1.5 Developing Professional Applications with Sheerpower
Sheerpower Rapid Development Environment makes professional application development easy with BUILT-IN TEMPLATES, and SPECIAL KEYSTROKES.
Some of Sheerpower's features are:
Plus many more special keystrokes that enable a programmer to quickly and efficiently write clean, readable and accurate code.
See Appendix I, Developing Professional Applications with Sheerpower for a detailed discussion on the special features built-in to Sheerpower designed to save time and money when creating professional applications.
See Appendix F, Keystrokes for Sheerpower Rapid Development Environment for a complete reference guide to the special keystrokes in Sheerpower Rapid Development Environment.
If you need to open an existing file stored on your computer to read or edit in SPDEV, click on the Open icon in the toolbar---an open file folder. You can then choose the directory and file you want to open from the OPEN dialog box that appears.
You can also open an existing file by clicking on File in the SPDEV toolbar, then selecting Open from the drop down menu. The Open dialog box will open.
Whether you are creating a new file or opening an existing file to edit in SPDEV, the default folder location is c:\sheerpower. The default file type being created/searched for is any of the Sheerpower program files (*.spsrc, *.int, *.spinc and *.inc).
SPDEV can open ANY kind of file that is not binary data. To open a different file type, click on the down arrow beside the Files of type: field (located at the bottom of the dialog box). Choose All Files to see all of files of the specified type within that folder.
To search for a file click on the down arrow beside the Look in: field (located at the top of the Open dialog box) and choose the folder you wish to search in.
If you make an compile or build error in your program, such as misspelling the word print, Sheerpower will display an error message in the Results Window (the bottom frame of SPDEV) in the Build tab. The error message with the line and column numbers will be in red text. Double-click directly on the line number given in the error message. Sheerpower will highlight the line of code containing the error for you in yellow and place the cursor at the start of the error in the program file. You can now make the correction and recompile your program.
When a main source program is run in Sheerpower Rapid Development Environment, the Sheerpower Console will open (also referred to as "the console" or "console window"). The console is a limited editing environment generally used for display and debugging purposes.
To open the console window without running a main source program, click on the Sheerpower Console icon in the SPDEV toolbar---the square with a lightning bolt through it.
To close the Sheerpower Console, type in exit and press the [Enter] key, or click the [x] in the top right corner of the window.
To learn more about the Sheerpower console and its debugging features, see Chapter 2, Debugging and Experimenting in Sheerpower.
When the console window is open after running a program from SPDEV, it must be closed before attempting to run the program again. The running man icon in the SPDEV toolbar will remain greyed out until the console window is closed. Only one program can be run from SPDEV at a time. Multiple instances of SPDEV can be opened. More than one instance of the Sheerpower console can be opened by clicking on the console window icon in the SPDEV toolbar. |
In SPDEV, you can get help by clicking on "Help" in the menu bar:
Selecting HELP in SPDEV or the console window will open up a new browser window that loads a local webpage containing links to this online documentation and other resources.
In some places in this manual, the format of statements and commands is represented abstractly. For example:
Format: [LET] var = expr |
Certain conventions are used to represent values which you (the user) must supply. These conventions are always shown in lowercase. These are the user conventions:
Symbol | Description |
---|---|
array | Array element. |
block of code | A Sheerpower statement or a series of Sheerpower statements. |
chnl | An I/O channel associated with a file. |
chnl_num | An I/O channel associated with a file. |
cond_expr | Conditional expression. |
col | Column. Used in the TAB or AT option to indicate the column to print at. |
const | Constant value. |
expr | Expression. May be a variable, constant, array element, structure reference, etc. or any combination of the previous, separated by operators. |
field_expr | Field name expression. |
func | Function. |
handl | Exception handler. Pertaining to an exception handling routine. |
handler | The block of code in an exception handler which is executed when an exception is generated. |
int | Integer value. |
int_expr | Integer expression. |
int_var | Integer variable. |
label | Alphanumeric statement label. |
libr | Pertaining to libraries. |
line_num | Program line number. |
name | Name. Indicates the declaration of a name or the name of a program unit, such as a subprogram. |
num | Numeric value. Num indicates that either a real or integer numeric value may be used. |
num_expr | Numeric expression. Num_expr indicates that either a real or integer numeric value may be used. |
num_var | Numeric variable. |
param | An expression which is passed to a function, subprogram or other program unit. A parameter can be any valid Sheerpower expression. |
protected block | The block of code protected by an exception handling routine. |
real | Real number. Indicates that only a real number may be used. |
row | Row. Used in the AT option to specify the row to print at. |
str | String. Str indicates that only a string value may be used. |
str_expr | String expression. |
str_var | String variable. |
struc | A Sheerpower structure. |
struc_name | Structure name. |
struc_expr | Structure expression. |
sub | A Sheerpower subprogram. |
target | The target point of a branch statement. The target can be either a program line number, an alphanumeric label, or a ROUTINE statement. |
uncond_expr | Unconditional expression. Uncond_expr indicates that only an unconditional expression can be used. |
var | Variable. May be a simple variable, array element or a structure reference. |
Previous | Next | Contents | Index |