| Previous | Contents | Index |
10.8.1 PASS [NOWAIT | NORETURN | WINDOW | TIMEOUT]
PASS [NOWAIT | NORETURN | WINDOW | TIMEOUT] [:] STRING_EXPR
|
The following example will run the calculator program in your computer.
| Example 10-30 PASS Statement |
|---|
input 'What program would you like to run': prog$ pass 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 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. By default, the Command Prompt window is completely suppressed when PASS is used.
Below is another example of the PASS statement. It puts the full names (including the full path) of all of the .SPSRC files into the text file called x.txt. This makes it easy for some program to then open the x.txt file, retrieve each file name and do something with it.
| Example 10-31 PASS Statement |
|---|
pass 'dir /s/b c:\sheerpower\*.spsrc > c:\sheerpower\x.txt' |
| Example 10-32 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-33 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 |
By default, the PASS statement suppresses the COMMAND PROMPT window. This then allows one to run commands in the background without the Command Prompt window displaying or flashing on the screen at all.
To display the Command Prompt window when the PASS statement is executed, use the PASS WINDOW: statement.
When a program is run from SPDEV, the Console Window will always open allowing you to debug the program. To test the PASS WINDOW: statement, run the program directly from the Console Window or save the program file and run it by double-clicking on the program file. In this way you will see the Command Prompt window when the PASS WINDOW: statement is used. When the debug console window is closed, any pending pass command is also terminated |
The following sample program will create a file called "x.txt" in your Sheerpower directory that contains a listing of the directory contents.
| Example 10-34 PASS WINDOW Statement |
|---|
pass window: 'dir>x.txt'
end
// file contents
Volume in drive C is OS
Volume Serial Number is 9999-4444
Directory of C:\Sheerpower
09/06/2008 06:45 PM <DIR> .
09/06/2008 06:45 PM <DIR> ..
07/24/2007 10:39 PM <DIR> ars
07/12/2008 10:38 PM <DIR> samples
07/12/2008 10:40 PM 127 sheerpower.ini
09/03/2008 11:43 PM 2,183,227 sp4gl.exe
09/06/2008 06:45 PM 498 sp4gl_system_info.txt
09/03/2008 11:41 PM 1,916,993 SPDev.exe
09/05/2008 09:06 PM 889 spdev_nonsp_user.ini
09/06/2008 06:38 PM 5,710 spdev_profile_user.ini
09/05/2008 06:32 PM 9,404 spdev_sp4gl_user.ini
09/06/2008 05:51 PM 472 spdev_system_info.txt
07/25/2007 10:35 AM 4,517 spdev_tools_user.ini
07/24/2007 10:39 PM <DIR> spdoc
09/01/2008 03:31 PM <DIR> sphandlers
08/31/2008 10:43 PM <DIR> sptools
09/05/2008 06:33 PM 1,151 Uninstall.dat
09/05/2008 06:33 PM 200,704 Uninstall.exe
09/06/2008 06:46 PM 0 x.txt
12 File(s) 4,323,692 bytes
7 Dir(s) 34,208,325,632 bytes free
|
PASS WINDOW will work with the NOWAIT, NORETURN and TIMEOUT options. The sample program below will create a file called "y.txt" in your Sheerpower directory that contains a list of the contents of the directory.
| Example 10-35 PASS NOWAIT | NORETURN, WINDOW: |
|---|
pass nowait, window: 'dir>y.txt'
end
// file contents
Volume in drive C is OS
Volume Serial Number is 9999-4444
Directory of C:\Sheerpower
09/06/2008 06:45 PM <DIR> .
09/06/2008 06:45 PM <DIR> ..
07/24/2007 10:39 PM <DIR> ars
07/12/2008 10:38 PM <DIR> samples
07/12/2008 10:40 PM 127 sheerpower.ini
09/03/2008 11:43 PM 2,183,227 sp4gl.exe
09/06/2008 06:45 PM 498 sp4gl_system_info.txt
09/03/2008 11:41 PM 1,916,993 SPDev.exe
09/05/2008 09:06 PM 889 spdev_nonsp_user.ini
09/06/2008 06:38 PM 5,710 spdev_profile_user.ini
09/05/2008 06:32 PM 9,404 spdev_sp4gl_user.ini
09/06/2008 05:51 PM 472 spdev_system_info.txt
07/25/2007 10:35 AM 4,517 spdev_tools_user.ini
07/24/2007 10:39 PM <DIR> spdoc
09/01/2008 03:31 PM <DIR> sphandlers
08/31/2008 10:43 PM <DIR> sptools
09/05/2008 06:33 PM 1,151 Uninstall.dat
09/05/2008 06:33 PM 200,704 Uninstall.exe
09/06/2008 06:46 PM 0 y.txt
12 File(s) 4,323,692 bytes
7 Dir(s) 34,208,325,632 bytes free
|
PASS TIMEOUT allows you to specify the maximum amount of time for a command to complete (in seconds). If the command has not already completed before the time specified, it will be completed at that time, and regular processing will continue.
The TIMEOUT option has no effect if used with NOWAIT and NORETURN. It does work with the WINDOW option.
The following sample program will open the Windows Calculator program, and close it automatically after 10 seconds has passed.
| Example 10-36 PASS TIMEOUT: |
|---|
pass timeout 10: 'calc' end |
pass print: string_expr |
| Example 10-37 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-38 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.
| Previous | Next | Contents | Index |