arg_val()

arg_val() returns arguments passed when running the application. The number of the argument returned is passed to the function as its parameter.

Syntax

arg_val({0, ordinal})

Parameters

ordinal

a positive INTEGER no greater that the total number of the arguments passed when running an application

Possible values

0

returns the name of the application and its deployment path

any ordinal

returns the argument which number is passed to the function as its parameter

Usage and examples

arg_val() returns one or several arguments passed when running the application according to the parameter of arg_val():

DISPLAY arg_val(2) AT 4, 5

will result in this display:

If the parameter of arg_val() is 0 (zero), it returns the name of the application and its deployment path:

DISPLAY arg_val(0) AT 4, 5

 

The number of passed arguments can be retrieved by num_args().

With this simple program, you can display the application name and the passed arguments:

MAIN

  DEFINE i INT

    MENU "args"

      COMMAND "program"

        DISPLAY arg_val(0) AT 5, 5

      COMMAND "num_args"

        DISPLAY num_args() AT 6, 5

      COMMAND "arg_val"

        FOR i = 1 to num_args()

          DISPLAY "Argument ", i, " is ", arg_val(i) AT i + 6, 5

        END FOR

      COMMAND "exit"

        EXIT PROGRAM

    END MENU

END MAIN

 

arg_val() will return the arguments passed when running the application no matter how you have run it - in LyciaDesktop or LyciaWeb; from LyciaStudio or from the command line:

 

When specifying arguments for your applications, be careful with -arguments - arguments started by - (hyphen).

By default, Lycia treats some of them - e.g. -D, -o, -v, etc. - as qrun arguments.

In this case, Lycia will try to perform the corresponding qrun action - e.g., start debugging the application or generate verbose output - fail (because no program was specified), and close your application by timeout.

If you need these arguments, you can set the specified environment variable - QX_RUN_ARG_PREF - and assign a certain prefix to all the qrun commands. Then arg_val() will be able to read and return your -arguments:

 

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.