ARGV() Function - Command Argument




The ARGV() function returns the arguments passed to PRO/5 when invoked. ARGC returns the number of arguments passed on the command line. ARGV(0) always returns the fully qualified name of the PRO/5 executable. User-defined arguments are returned in ARGV(1), ARGV(2), etc., up to ARGV(ARGC-1). If there are no user-defined arguments, then ARGC is 1.

In PRO/5 5.0 and higher, a pro5 script that replaces the pro5 executable sets the environment and runs either the pro5b or pro5s executable. The installation script also sets the correct path information to the additional libraries installed in the pro5/lib directory for the new encryption capabilities. Since the pro5 script now executes pro5b or pro5s, the ARGV(0) reports the executable name that the pro5 script calls, not the script name. If an SCALL uses ARGV to invoke another session, which runs the executable rather than the script, the call fails.

As an alternative, set the LIBRARY_PATH environment variable to the library location or copy the library files to the operating system's shared library to run pro5 as an executable. Then copy the appropriate pro5b or pro5s file to pro5.

Assume that Visual PRO/5 was invoked with the following command line:

vpro5 -m1024 -tT8 –q -c"C:/Program Files/basis/vpro5/config.bbx" - 1 "My Company"

In this case there are 2 user-defined arguments, "1" and "My Company." User-defined arguments are separated from standard PRO/5 arguments by a single " - ". Individual arguments are separated by spaces. If embedded spaces are required, then the value must be quoted as shown.

The following code displays the user-defined arguments from the above example:

PRINT 'CS',"Number of command line arguments: ",ARGC
REM get the arguments using argv(0) through argv(argc-1)

Running this program with the command line above yields the result:

Number of command line arguments: 3
ARGV(0) = C:\Program Files\BASIS\VPRO5\vpro5.exe
ARGV(1) = 1
ARGV(2) = My Company

For additional information on setting the values returned by ARGC and ARGV(), see Invoking PRO/5, Command Line Options.

See Also

Functions - Alphabetical Listing