SYSTEM: Calling a System Program
Available Operating Systems: Windows
Available Languages: reporting
The SYSTEM function calls a DOS program, a batch program, or a Windows application from a procedure. SYSTEM passes a command string to DOS or Windows and the program is executed as if it had been entered at the DOS command-line or the command-line field in the Windows Program Manager Run dialog box. When you exit the program, control returns to WebFOCUS.
SYSTEM suspends FOCUS execution of subsequent commands until you exit the application. It has an advantage over the FOCUS DOS command, which also enables you to call DOS programs and Windows applications from a procedure.
When executing a command from SYSTEM, the command executes as follows:
- If the command name in the string passed to SYSTEM contains a .COM or .EXE extension, the command is called directly rather than using the DOS command interpreter.
- If the command name in the string does not contain a suffix or contains a .BAT extension, SYSTEM calls the DOS command interpreter COMMAND.COM to perform the specified command and then exit.
- SYSTEM passes
the following commands to FOCUS, not to the DOS command interpreter:
CD, CLS, COPY, DEL, DIR, drive:, REN, TYPE. As a result,
these commands are interpreted directly by FOCUS, not by DOS, and
you may observe a slightly different behavior. If you want SYSTEM
to pass these commands to the DOS command interpreter instead, use
the following syntax:
SYSTEM(length, 'COMMAND /C string', returncode)
Call a DOS or Windows Program
SYSTEM(length, 'string ', returncode)
Integer
Is the length, in characters, of string.
Alphanumeric
Is a valid Windows or DOS command with command-line parameters enclosed in single quotation marks.
Double precision
Is the name or length of the variable that contains the value of the DOS error level.
Executing the DIR Command
SYSTEM passes the DIR command to the DOS command interpreter to create a sorted directory listing with no heading information or summary, and redirects the output to a file named DIR.LIS:
-SET &RETCODE = SYSTEM(31,'COMMAND /C DIR /O-N /B >DIR.LIS','D4');