SYSTEM: Calling a System Program

How to:

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:

Syntax: How to Call a DOS or Windows Program

SYSTEM(length, 'string ', returncode)

where:

length

Integer

Is the length, in characters, of string.

string

Alphanumeric

Is a valid Windows or DOS command with command line parameters enclosed in single quotation marks.

returncode

Double precision

Is the name or length of the variable that contains the value of the DOS error level.

Example: 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');

Example: Changing the Default Directory

SYSTEM changes the default directory and suspends processing until the operation is complete:

-SET &ERRORLEVEL = SYSTEM(15,'CHDIR \CARDATA','D4');

Example: Running the Check Disk Program

SYSTEM runs the check disk program and redirects the output to a file called CHKDSK.TXT. (Redirecting the output to a file makes it accessible to a program that might want to read it.)

-SET &RETCODE=SYSTEM(19,'CHKDSK > CHKDSK.TXT','D4');