Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

10.8 Pass Commands to the Operating System

10.8.1 PASS [NOWAIT | NORETURN | WINDOW | TIMEOUT]

FORMAT:


    PASS [NOWAIT | NORETURN | WINDOW | TIMEOUT] [:] STRING_EXPR 

EXAMPLE:

Important note on the following example:

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' 

PURPOSE:

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.

DESCRIPTION:

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.

10.8.1.1 PASS NOWAIT

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:

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

10.8.1.2 PASS NORETURN

The PASS NORETURN statement passes a command to the operating system but does not return to SheerPower.

EXAMPLE:

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 

10.8.1.3 PASS WINDOW

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 the SP4GL Console Window is displayed

When a program is run from SPDEV, the SP4GL Console Window will always open allowing you to debug the program. To test the PASS WINDOW: statement, run the program directly from the SP4GL 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:

Example 10-33 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-34 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 
 

10.8.1.4 PASS TIMEOUT

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:

Example 10-35 PASS TIMEOUT:

  pass timeout 10: 'calc' 
  end
  

10.8.2 PASS PRINT

FORMAT:


  pass print: string_expr 

EXAMPLE:

Example 10-36 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

PURPOSE:

The PASS statement can be used to print output from SheerPower.

DESCRIPTION:

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.

10.8.3 PASS URL

FORMAT:


  pass url: str_exp 

EXAMPLE:

Example 10-37 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

PURPOSE:

PASS URL opens any URL. The above example illustrates PASS URL opening an .HTML file.

DESCRIPTION:

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


Previous Next Contents Index