| Previous | Contents | Index |
CASE IS is used to form a conditional expression to be checked against the main expression. The format of the CASE IS option is:
CASE IS {relational operator} expr
|
When the CASE IS statement executes, SheerPower compares expr to the main_expr using the relational operator.
| Example 10-28 CASE IS statement |
|---|
do
input 'Your income per year': income
if _back or _exit then exit do
select case income
case 0
print 'No income?'
case is < 0
print 'A negative income? You are in debt!'
case is > 0
print 'A positive income.'
end select
loop
end
Your income per year? -15000
A negative income? You are in debt!
Your income per year? 0
No income?
Your income per year? 25000
A positive income.
Your income per year? exit
|
CHAIN 'file_spec'
|
| Example 10-29 CHAIN statement |
|---|
line input 'Your name (last, first)': name$ open #1: name 'storage.txt', access output print #1: name$ close #1 input 'Add to CLIENT structure (Y/N)': reply$ if reply$ = 'Y' then chain 'ADD' end Your name (last, first)? Woods, Jack Add to CLIENT structure (Y/N)? N |
CHAIN exits the current program and runs the program specified.
file_spec is the specification for the program being chained to. The file specification can be any string expression. SheerPower searches for the file specified, then exits the current program and runs the program named. Control does not return to the current program when the chained program is finished. If SheerPower cannot find the file, or if the file is not an executable program, an exception is generated.
When SheerPower executes the CHAIN statement, it:
10.8.1 PASS [NOWAIT: | NORETURN:]
PASS [NOWAIT: | NORETURN:] str_expr
|
The following example will run the calculator program in your computer. |
| Example 10-30 PASS [NOWAIT: | NORETURN:] |
|---|
input 'What program would you like to run': prog$ pass 'start ' + prog$ end What program would you like to run? calc <--------- type in 'calc' |
PASS is used to perform system commands without leaving the SheerPower environment or exiting a program. In Windows, SheerPower passes the command to the operating system.
SheerPower supports using the PASS command from a captive account. This allows you to use SheerPower 4GL for captive menu situations.
PASS passes the specified string expression to the operating system command interpreter. Generally, it passes the string to the operating system. The operating system will respond to the string as it would if you entered it at the DOS prompt. When the system finishes, control returns to the SheerPower program.
When the NOWAIT option is used with PASS, the operating system executes the passed command and immediately returns to SheerPower without waiting for the passed command to finish.
| Example 10-31 PASS NOWAIT statement |
|---|
print 'Start the calculator' pass 'calc' print 'We are back from using the calculator' delay print 'Now we start the calculator, but return instantly.' pass nowait: 'calc' print 'We are back already -- even though the calculator is still active.' delay end |
The PASS NORETURN statement passes a command to the operating system but does not return to SheerPower.
| Example 10-32 PASS NORETURN statement |
|---|
print 'B E F O R E' delay 2 pass noreturn: 'calc' //<--- start up Windows calculator end B E F O R E |
pass print: string_expr |
| Example 10-33 PASS Print |
|---|
// Create your output text file:
outfile$ = 'myfile.txt'
open file out_ch: name outfile$, access output
for i=1 to 100
print #out_ch: i, sqr(i)
next i
close #out_ch
// Now print it out to the default printer
pass print: outfile$
end
|
The PASS statement can be used to print output from SheerPower.
PASS PRINT will locate the program associated with the filetype being used, then ask that program to print the file to whatever printer is currently selected for that application.
pass url: str_exp |
| Example 10-34 PASS URL: Opening an .HTML file |
|---|
// Create your output html file
outfile$ = 'myfile.html'
open file out_ch: name outfile$, access output
print #out_ch: '<html><body>'
print #out_ch: '<table border=3 bgcolor=lightblue>'
for i=1 to 100
print #out_ch: '<tr>'
print #out_ch: '<td>'; i; '<td>'; sqr(i)
print #out_ch: '</tr>'
next i
print #out_ch: '</table>'
print #out_ch: '</body></html>'
close #out_ch
// Now envoke the browser to open the file.
pass url: outfile$
end
|
PASS URL opens any URL. The above example illustrates PASS URL opening an .HTML file.
The PASS URL statement can be used to open any webpage, either local or remote. A new browser window is opened by PASS URL. If the URL references a filetype handled by an external program (such as an .AVI movie file), then the appropriate external program will be run (such as the Windows Media Player).
By using the PASS URL statement, web-based applications and multi-media features can be integrated into SheerPower 4GL applications
DISPATCH str_expr
.
.
.
target
---
--- block of code
---
END ROUTINE
|
| Example 10-35 DISPATCH statement |
|---|
input 'Routine name', default 'add_info': routine$ dispatch routine$ stop routine add_info print 'Adding information...' end routine change_info print 'Changing information...' end Routine name? add_info Adding information... |
DISPATCH executes a routine that the program determines at runtime.
DISPATCH looks at the contents of the string expression (str_expr), searches for a routine with that name and goes to the routine.
str_expr is the name of the subroutine to execute.
| Previous | Next | Contents | Index |