Skip to content

Cmdline

Obsolete

This command is replaced by the cCommandLine class.

See Also

Purpose

To move arguments from the command line of the current DataFlex program into variables.

Syntax

Cmdline {variable}

What It Does

A command line is a string of arguments that follow the program name when a DataFlex program is executed. The user may enter the command line (e.g., by using the Run Dialog of the Windows Start Menu) or it can be programmatically set (e.g., by using Runprogram or Chain to execute a DataFlex program).

Command line arguments are space-delimited strings that follow the name of the program. Arguments that contain spaces themselves must be quoted.

Example

Here is a simple program that prints all the command line arguments passed to a program:

Use DFallent

Object oPanel is a Panel
    Set Size to 100 100

    Object oTest Is A Button
        Set Location to 10 10

        Procedure OnClick
            String sCommandLineParameter
            Integer iCounter

            Showln "Show command line parameters."
            Cmdline sCommandLineParameter

            While (sCommandLineParameter <> "")
                Showln "Parameter " Counter ": " sCommandLineParameter
                Cmdline sCommandLineParameter
                Increment iCounter
            Loop
        End_Procedure
    End_Object
End_Object

Start_UI

Assuming the program above is called "Test", the command line:

\path\MyProjectName.Exe "Parameter 1" Parameter2 3

…will return 3 arguments: "Parameter 1", "Parameter2", and "3".

Notes

  • Cmdline retrieves arguments in the order in which they are given on the command line. For example, the third Cmdline command in the program will retrieve the third argument on the command line.

  • If a Cmdline command is executed after all arguments on the command line have been consumed, the {variable} named in the command will be empty.

  • Once all the command line arguments are read by the system, they are no longer available for subsequent Cmdline commands.