To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
The ARG_VAL( ) function returns a specified argument from the command line that invoked the current 4GL application program. It can also return the name of the current 4GL program.
ARG_VAL () takes an ordinal as its argument. This should be a positive integer expression that is no higher that the number of arguments in the program. (You can use the NUM_ARGS( ) function to determine how many arguments follow the program name on the command line.)
This function provides a mechanism for passing values to the 4GL program through the command line that invokes the program. You can design a 4GL program that expects or allows arguments to appear in the command line, after the program name.
You can use the ARG_VAL() function to pass values to MAIN, which cannot have its own formal arguments. ARG_VAL( ) can be called from any part of the program, not just the MAIN statement.
You can use ARG_VAL( ) to retrieve individual arguments during program execution.
If 1 ≤ ordinal = n, ARG_VAL(n) returns the nth command-line argument, as a character string. The value of ordinal must be between zero and the value returned by NUM_ARGS ( ), the number of command-line arguments.
Using ARG_VAL( ) with NUM_ARGS( )
The built-in ARG_VAL( ) and NUM_ARGS( ) functions can pass data to a compiled 4GL program from the command line that invoked the program.
For example, suppose that the 4GL program called program_arguments can accept one or more account names as command-line arguments (in order to process account reports).
program_arguments St MegaSoft01 Querix02 Provia03
In either case, statements in the following program fragment use the ARG_VAL( ) function to store in an array of CHAR variables all the names that the user who invoked program_arguments entered as command-line arguments:
MAIN
DEFINE
args ARRAY[8] OF CHAR(10),
i, line_disp SMALLINT,
str_disp char(50)
FOR i = 1 TO NUM_ARGS()
LET args[i] = ARG_VAL(i)
END FOR
LET str_disp = "Total Number of passed arguments: ", NUM_ARGS()
DISPLAY str_disp at 2, 5
FOR i = 1 TO NUM_ARGS()
LET line_disp = i + 5
LET str_disp = "Argument " , i, " was ", args[i]
DISPLAY str_disp at line_disp , 5
END FOR
call fgl_getkey()
END MAIN
After program_arguments is invoked by these command-line arguments, the NUM_ARGS( ) function returns the value 3. Executing the LET statements in the FOR loop assigns the following values to elements of the args array.
Variable |
Value |
args(1) |
Megasoft01 |
args(2) |
Querix01 |
args(3) |
Provia01 |
Related articles:
Multiple Parameters