Was this helpful?
CommandLineParameters( )
Retrieves application-specific parameters from the operating system command line.
Syntax
returnfield = [callproc] CommandLineParameters( )
returnfield
A varchar variable into which the result is returned. If the application‑specific parameters are too large to fit into this variable, they are truncated on the right.
Description
The CommandLineParameters( ) procedure retrieves an application-specific parameter that you specify on the command line when starting an imaged application. The parameter is retrieved into a varchar value of the size necessary to hold the parameter.
You can call this procedure from any frames or procedures within the application. You can call the function as many times as needed within an application; it always returns the same value.
If you allow a user to specify multiple parameters, the parameters are passed as a single string value. This string begins after the -a command line flag (described in the ABF part of this guide).
The parameters are concatenated with a single space separating adjacent parameters. You must be aware of any peculiarities of your operating system in the way it parses character strings into separate parameters (for example, in handling embedded quotes or multiple contiguous spaces).
You can use the SQL string functions described in the SQL Reference Guide to parse this string into the individual variables used by your application.
Although the CommandLineParameters() procedure is intended primarily for use with imaged applications, you also can use it with an interpreted application. In such a case, the first call to the procedure causes you to be prompted for up to 74 bytes of application‑specific parameters.
See Examples for 4GL code that you can use to parse multiple command line parameters.
Examples
The following 4GL statement retrieves your department number as entered on the command line when you start the application:
deptno = callproc CommandLineParameters()
For example, you might enter the following command to start an application called Deptapp:
deptapp -a 567
In this case, the variable deptno contains the string '567.' (The space between the -a and the value is required.)
String Parsing Example
The following 4GL code uses built-in SQL string functions to retrieve an employee's department, division and building as entered on the command line. The data is stored in a varchar buffer called "empdata." In the example, "s" is a varchar work variable and "I" is an integer work variable.
Empdata = callproc CommandLineParameters();
s = squeeze ( empdata );
I = locate ( s, ' ' ); dept = left ( s, I - 1 ); s = shift ( s, -I );
I = locate ( s, ' ' ); div = left ( s, I - 1 ); s = shift ( s, -I );
I = locate ( s, ' ' ); bldg = left ( s, I - 1 ); s = shift ( s, -I );
if s != ' ' then 
     message 'extraneous words entered in empdata ' + s
        with style = popup;
endif;
If you enter the following command to start the Empapp application:
empapp -a widget manufacturing 123A
Then the following values are returned:
The variable dept contains 'widget'
The variable div contains 'manufacturing'
The variable bldg contains '123A'
See the SQL Reference Guide for more information about the string functions used in the above example.
Last modified date: 08/28/2024