SCALL() Function - System Call

Syntax

SCALL(string{,ERR=lineref})

Description

For BBj-specific information, see SCALL() Function - BBj.

The SCALL() function is used in run mode to execute operating system commands in the PRO/5 environment.

Parameters

Parameter Description
string Any valid operation system command. For example, the command "dir" is passed to the operating system command processor for execution: A=SCALL("dir")
ERR=lineref Branch to be taken if an error occurs during execution.

Return Code

A defined variable for the SCALL() function is set with a return code that reflects the operation's success or failure. The operating system manual contains information on return code values.

A return code of 32767 is an indication of an abnormal termination. This can happen when the scalled process is killed by a kill command or a kill signal.

Note:

Because SCALL() is system specific, use caution.

Operating system commands are not written in PRO/5, and so are non-portable. For example, although Microsoft Windows is, in effect, "hosted" by MS-DOS, it is an operating system in its own right, with its own sets of rules. DOS-intrinsic commands (DIR, COPY) are not directly implemented in executable files but are built into the command interpreter.

It is possible to execute any Windows or DOS executable file (.com, .exe, .bat, .pif, and the like) from Visual PRO/5. Windows can automatically determine whether the file in question is a DOS or Windows executable. However, only the .exe extension is supplied by default. To run a .com or .bat file, it is necessary to specify the extension. The directories listed in the PATH environment variable are searched.

System Call Types

PRO/5 and Visual PRO/5 support two types of system calls: synchronous and asynchronous. In synchronous system calls, the interpreter waits until the system command is completed to resume operation. This is the default. In asynchronous system calls, the program commands after the SCALL are executed while the system call is executing. To set a system call to asynchronous, insert an ampersand (&) as the last character in the command line.

Examples

Example 1

The following is an MS-DOS SCALL() command:

1000 VAL=SCALL("copy /basis/prog1 /basis/prog2")

Example 2

The following is a Windows 95/98 SCALL() command to execute the DIR command via the command interpreter:

1000 A=SCALL("C:\command.com /c dir")

Example 3

The following is a Windows NT/2000 SCALL() command to execute the DIR command via the command interpreter:

1000 A=SCALL("CMD.EXE /c dir")

Example 4

The following is a UNIX operating system SCALL() command:

1000 A=SCALL("ls -l")

See Also

Functions - Alphabetical Listing