The console

The Workbench includes a powerfule "console" where you can, during the development of a project, run some operations in "command line" text mode instead of using menus. This may be very useful to automate some repetitive tasks or quickly manipulate objects of huge projects.

While editing, go in the "Prompt" tab of the output window:

Enter the command "?" to get the list of availablae commands and their syntax. Below are available commands, sorted by categories.

Special commands:

? Display help
HELP Display help (same as "?")
FOR Iterate a command

Managing programs:

CreateProgram Create a main program
CreateSP Create a sub-program
CreateUDFB Create a User Defined Function Block
CreateSfcChild Create a child SFC program
CopyProgram Duplicate a program
DeleteProgram Delete a program
EnumProgram Enumerate programs
GetProgram Get information about a program

Managing program folders:

CreateFolder Create a folder of programs
SendToFolder Send a program to a folder
DeleteFolder Delete a folder
EnumFolder Enumerate folders

Managing variables:

CreateVar Create a variable
CreateInParam Create an input parameter
CreateOutParam Create an output parameter
DimVar Set variable dimensions
DeleteVar Delete a variable
InitVar Set variable initial value
SybVar Specifies whether the symbol of a variable must be embedded
ProfileVar Set variable profile and embedded properties
EnumVar Enumerate variables
GetVar Get information about a variable
GetVarProp Get variable embedded properties

Managing data types (structures):

CreateStruct Create a structure
DeleteStruct Delete a structure
EnumStruct Enumerate structures

Managing I/O boards:

CreateIO Create an instance of an IO device
IOParam Set a parameter of an IO board
IOAlias Give an alias to an IO channel
DeleteIO Delete an instance of an IO device
EnumIO Enumerate IO boards
GetIO Get information about an IO board

Managing comment texts:

Comm Set comment text
Tag Set short comment text (tag) - variables only
GetComm Display a comment text
GetTag Display a short comment text (tag) - variables only


Below are detailed information about commands.

? / HELP - Display help

Syntax:

    HELP [ command ]
    ? [ command ]

Arguments:

    command : name of the command you want help about

Notes:

If no "command" argument is specified, then HELP lists all possible commands.

FOR - Iterate a command

Syntax:

    FOR <min> TO <max> <command> [ args ]

Arguments:

    min : first enumeration integer value (see notes)

    max : last enumeration integer value (see notes)

    command : command to execute

    args : arguments of the command

Notes:

In command arguments, you can use the special '%' characters, to be replaced with the iteration number. If you specify consecutive '%' characters, this represents the iteration index formatted on several characters, completed on the left by '0' digits'. For example, the command:

    FOR 1 TO 3 CreateProgram LD Prog%%

creates 3 LD programs called Prog01, Prog02 and Prog03

Note that not all commands support FOR iterations. See details about specific commands for further information.

CreateProgram - Create a main program

Syntax:

    CreateProgram <language> <name>

Arguments:

    language : SFC or FBD or LD or ST or IL

    name : program name

Notes:

The program is created at the end (after the last existing program) of the cycle.

This command can be used in a "FOR" loop.

CreateSP - Create a sub-program

Syntax:

    CreateSP <language> <name>

Arguments:

    language : FBD or LD or ST or IL

    name : sub-program name

Notes:

This command can be used in a "FOR" loop.

CreateUDFB - Create a User Defined Function Block

Syntax:

    CreateUDFB <language> <name>

Arguments:

    language : FBD or LD or ST or IL

    name : function block name

Notes:

This command can be used in a "FOR" loop.

CreateSfcChild - Create a child SFC program

Syntax:

    CreateSfcChild <parent> <name>

Arguments:

    parent : name of the parent SFC program

    name : sub-program name

Notes:

This command can be used in a "FOR" loop.

CopyProgram - Duplicate a program

Syntax:

    CopyProgram <program> <newprogram>

Arguments:

    program : name of the source program

    newprogram : name of the destination program to be created

Notes:

This command is used for creating copies of a program. It should not be used for overwriting an existing program.

This command can be used in a "FOR" loop.

DeleteProgram - Delete a program

Syntax:

    DeleteProgram <program>

Arguments:

    program : program to delete - may contains '?' wildchars

Notes:

This command can be used in a "FOR" loop.

EnumProgram - Enumerate programs

Syntax:

    EnumProgram [ filter ]

Arguments:

    filter : filtering strings - may contain '*' and '?' wildchars

Notes:

This command cannot be used in a FOR loop

GetProgram - Get information about a program

Syntax:

    GetProgram <program>

Arguments:

    program : program name

Notes:

This command cannot be used in a FOR loop

CreateFolder - Create a folder of programs

Syntax:

    CreateFolder <name>

Arguments:

    name : folder name

Notes:

The folder is created under the root folder of the workspace. Nested folders are not supported by this command.

This command can be used in a "FOR" loop.

SendToFolder - Send a program to a folder

Syntax:

    SendToFolder <program> <folder>

Arguments:

    program : name of a program, sub-program or UDFB

    folder : name of an existing folder under the root folder

Notes:

The destination folder must exist and be under the root folder of the workspace. Nested folders are not supported by this command.

This command can be used in a "FOR" loop.

DeleteFolder - Delete a folder

Syntax:

    DeleteFolder <folder>

Arguments:

    folder : folder name

Notes:

The destination folder must exist and be under the root folder of the workspace. Nested folders are not supported by this command.

This command can be used in a "FOR" loop.

EnumFolder - Enumerate folders

Syntax:

    EnumFolder [ filter ]

Arguments:

    filter : filtering strings - may contain '*' and '?' wildchars

Notes:

This command cannot be used in a FOR loop

CreateVar - Create a variable

Syntax:

    CreateVar <name> <type>

Arguments:

    name : name of the variable - see notes

    type : data type (can be a function block to create an instance)

Notes:

This function is used for declaring a variable, or for adding an item to a data structure. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

CreateInParam - Create an input parameter

Syntax:

    CreateInParam <POU>.<name> <type>

Arguments:

    POU : name of the sub-program or UDFB

    name : name of the parameter

    type : data type (can be a function block to create an instance)

Notes:

This command can be used in a FOR loop

CreateOutParam - Create an output parameter

Syntax:

    CreateOutParam <POU>.<name> <type>

Arguments:

    POU : name of the sub-program or UDFB

    name : name of the parameter

    type : data type (can be a function block to create an instance)

Notes:

This command can be used in a FOR loop

DimVar - Set variable dimensions

Syntax:

    DimVar <var> <Dim1> [ Dim2 [ Dim3 ] ]

Arguments:

    var : name of the variable - see notes

    dim1, dim2, dim3 : dimensions (for highest to lowest)

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

DeleteVar - Delete a variable

Syntax:

    DeleteVar <var>

Arguments:

    var : name of the variable - see notes

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

InitVar - Set variable initial value

Syntax:

    InitVar <var> [ value ]

Arguments:

    var : name of the variable - see notes

    value : initial value (initial value is removed if this argument is omitted)

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

SybVar - Specifies whether the symbol of a variable must be embedded

Syntax:

    SybVar <var> < ON | OFF >

    var : name of the variable - may contain '*' and '?' wildchars - see notes

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

ProfileVar - Set variable profile and embedded properties

Syntax:

    ProfileVar <var> [ profile [ props ] ]

Arguments:

    var : name of the variable - may contain '*' and '?' wildchars - see notes

    profile : profile name - the profile is removed if not specified

    pros : embedded properties - properties are removed if not specified

Notes:

Properties are written as 'name=value,name=value...' such as shown in the variable editor.

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop

EnumVar - Enumerate variables

Syntax:

    EnumVar [ filter ]

Arguments:

    filter : filtering strings - may contain '*' and '?' wildchars

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The filtering string must be prefixed with its group name and the '.' separator. Variables are considered as GLOBAL if no prefix is specified. Below are some examples:

* global variables
RETAIN.* RETAIN variables
ProgName.* variables local to a program
UDFBName.* parameters of a UDFB
StructName.* items of a data structure

This command cannot be used in a FOR loop

GetVar - Get information about a variable

Syntax:

    GetVar <var>

Arguments:

    var : name of the variable - see notes

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command cannot be used in a FOR loop

GetVarProp - Get variable embedded properties

Syntax:

    GetVarProp <var>

Arguments:

    var : name of the variable - see notes

Notes:

This function is used for variables, parameters of sub-programs and UDFBs or for items of data structures. The name of the variable must be prefixed with its group name and the '.' separator. The variable is considered as GLOBAL if no prefix is specified. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command cannot be used in a FOR loop

CreateStruct - Create a structure

Syntax:

    CreateStruct <name>

Arguments:

    name : structure name

Notes:

This command can be used in a FOR loop

DeleteStruct - Delete a structure

Syntax:

    DeleteStruct <struct>

Arguments:

    struct : structure name

Notes:

This command can be used in a FOR loop

EnumStruct - Enumerate structures

Syntax:

    EnumStruct [ filter ]

Arguments:

    filter : filtering strings - may contain '*' and '?' wildchars

Notes:

This command cannot be used in a FOR loop

CreateIO - Create an instance of an IO device

Syntax:

    CreateIO <slot> <IOtype>

Arguments:

    slot : slot number (0 .. 255)

    IOtype : type of IO device

Notes:

This command cannot be used in a FOR loop

IOParam - Set a parameter of an IO board

Syntax:

    IOParam <%board> <name> <value>

Arguments:

    %board : address of the IO board (e.g. %QX0)

    name : name of the parameter

    value : value for the parameter

Notes:

This command cannot be used in a FOR loop

IOAlias - Give an alias to an IO channel

Syntax:

    IOAlias <%channel> <alias>

Arguments:

    %channel : address of the IO channel (e.g. %QX0.1)

    alias : readable name to be used as an alias

Notes:

This command cannot be used in a FOR loop

DeleteIO - Delete an instance of an IO device

Syntax:

    DeleteIO <slot>

Arguments:

    slot : slot number (0 .. 255)

Notes:

This command cannot be used in a FOR loop

EnumIO - Enumerate IO boards

Syntax:

    EnumIO

Notes:

This command cannot be used in a FOR loop

GetIO - Get information about an IO board

Syntax:

    GetIO <%board>

Arguments:

    %board : address of the IO board (e.g. %QX0)

Notes:

This command cannot be used in a FOR loop

Comm - Set comment text

Syntax:

    Comm <X|P|S|V|B> <name> <comment>

Arguments:

    name : object name

    comment : comment text

Notes:

Use the following values for the first argument that specifies the kind of object:

X : project
P : program or sub-program or UDFB
S : structure
V : variable
B : IO board

In case of a variable, the name must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop, except or IO boards

Tag - Set short comment text (tag) - variables only

Syntax:

    Tag V <name> <comment>

Arguments:

    name : variable name (see notes)

    comment : short comment text (tag)

Notes:

The name of the variable must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop, except or IO boards

GetComm - Display a comment text

Syntax:

    GetComm <X|P|S|V|B> <name>

Arguments:

    name : object name

Notes:

Use the following values for the first argument that specifies the kind of object:

X : project
P : program or sub-program or UDFB
S : structure
V : variable
B : IO board

In case of a variable, the name must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command cannot be used in a FOR loop

GetTag - Display a short comment text (tag) - variables only

Syntax:

    GetTag V <name>

Arguments:

    name : variable name (see notes)

Notes:

The name of the variable must be prefixed by the group namle follosed by the '.' separator. Below are some examples:

VarName a global variable
RETAIN.VarName a RETAIN variable
ProgName.LocVarName a variable local to a program
UDFBName.ParamName a parameter of a UDFB
StructName.Item an item of a data structure

This command can be used in a FOR loop, except or IO boards