KSL commands and variables
This chapter describes commands and variables used in KSL scripts.
CommandsLink copied to clipboard
Certain commands accept KSL and/or AutoEdit variables. When both KSL and AutoEdit variables are specified, KSL variables are resolved (replaced) first.
Table 2 KSL Screen Commands
Command |
Description |
---|---|
CLEAR |
Equivalent to pressing the Clear key on the keyboard. |
CURSOR |
Depending on the parameters listed below, CURSOR moves the cursor to the
|
ENTER |
Equivalent to pressing the Enter key on the keyboard. |
FIND{‘textstring’|expression} |
Searches for text on the screen from the current position of the cursor. If the text is found, the cursor is positioned at the beginning of the text. For more information, see special variable %FINDRC, described in Table 6 in Special KSL Variables.
|
PA01-PA03 |
Equivalent to pressing program attention keys on the keyboard. |
PF01-PF24 |
Equivalent to pressing program function keys on the keyboard. |
SCREENSIZE line-no col-no |
Defines the logical terminal size. Valid terminal sizes are:
|
TYPE{‘textstring’ | expression} |
Operates the keyboard by "typing" the text on the screen from the current position of the cursor. If the text is too long for the current data field, an error message is produced and the script stops executing.
|
Table 3 KSL Flow Commands
Command |
Description |
---|---|
CALL progname [argument1argument2 ... argumentn] |
Calls an external program (progname). The arguments are optional. A maximum of nine arguments can be passed. Use command CALL when the called program expects to receive a list of parameters. The parameters are passed in a format compatible with ASSEMBLER, COBOL and FORTRAN.
Note: The return code of the called program is stored in special variable %CALLRC, which is described in Table 6 on page 38. |
CALLMEM memname [argument1argument2 ... argumentn] |
Calls a predefined KSL script that is located in the member memname in the library allocated to the DACALL DD statement. The arguments are optional. A maximum of nine arguments can be passed. The return code of the called program is stored in special variable %CALLRC, which is described in Table 6 on page 38. |
END |
Indicates the end of the KSL script. This is a mandatory command in the main script commands list. When activated at any level, the script is terminated. |
EXEC progname [argument1argument2 ... argumentn] |
Calls an external program (progname). The arguments are optional. A maximum of nine arguments can be passed. Use command EXEC when the called program expects to receive an argument in a format similar to JCL’s EXEC PGM argument format. (All arguments are merged into a single argument.)
(Described later in this chapter). The return code of the called program is stored in variable %CALLRC, which is described in Table 6 in Variables. |
GOTO label_name |
Branches to the specified label name, which must be in the same command member. |
|
If all parts of the conditional expression evaluate to true, script flow branches to the specified label name, which must be in the same command member. A parameter cannot be specified more than once within the same conditional expression. Each part of the conditional expression is true if the:
|
IFSCREEN (continued) |
|
IFVAR operand operator operand GOTO labname |
Where:
Operands are compared as character strings from left to right. For example, 91 is greater than 1000, because 9 is greater than 1. IFVAR is used together with command GOTO to permit branching based on different runtime conditions. If the condition is true, flow branches to the specified label name (must be in the same command member). |
LABEL name |
Defines a label to which script flow can branch. |
MAXCOMMAND number |
number is the maximum number of commands that can be executed in the script. Default: 400. This is designed to prevent an accidental loop. |
PAUSE n |
Where n= hundredths of seconds. Causes the script to "wait" the specified amount of time. |
RETURN [return-code] |
Returns to the calling script. return-code must be a number from 0 through 4095. When command RETURN is activated, control is passed to the command after the CALLMEM command in the calling member. The variable %CALLRC in the calling member is set to the value of the return code. Default: 0. |
Table 4 KSL Print Commands
Command |
Description |
---|---|
BOTTOMLINE line-nopos-in-line {‘textstring’|varname} |
Assigns contents to a line in the page footer. The footer contents are valid throughout the script until overridden by another BOTTOMLINE command for the same line in overlapping positions. Command BOTTOMSIZE overrides the current BOTTOMLINE specifications.
|
BOTTOMSIZE line-no |
Specifies the number of lines in the report bottom (footer) (1 minimum – 15 maximum). The bottom size is valid throughout the script until a new BOTTOMSIZE command is activated. |
HEADERLINE line-nopos-in-line {‘textstring’|varname} |
Assigns contents to a line in the page header. The header contents are valid throughout the script until overridden by another HEADERLINE command for the same line in overlapping positions. Command HEADERSIZE overrides the current HEADERLINE specifications.
|
HEADERSIZE line-no |
Specifies the number of lines in the report header (1 minimum – 15 maximum). The header size is valid throughout the script until a new HEADERSIZE command is activated. |
PAGESIZE line-no col-no |
Defines the maximum size of a printed page.
|
PRINTLINE line-no |
Prints the contents of the line identified by line-no (a number from 1 through 9999). |
PRINTNEWPAGE |
Skips to a new page. Each occurrence of command PRINTNEWPAGE in a KSL script must be preceded by commands SCREENSIZE, PAGESIZE, HEADERSIZE and BOTTOMSIZE. |
PRINTSCREEN from-line until-line |
Prints the screen contents of the specified line range.
|
SETLINE identifier pos-in-line font {‘textstring’|varname} |
Assigns contents to a line that is about to be printed.
|
TRACE {ON|OFF} |
Simplifies problem resolution using the TRACE (debug) facility while defining a script.
|
Table 5 KSL Processing Commands
Command |
Description |
---|---|
ALLOC DD ddname DS dsname[MEM memname][{SHR|OLD|MOD}] |
Dynamically allocates the data set dsname to the specified DD name.
Before a data set can be accessed (for example, with OPENFILE, GETFILE), it must be allocated and assigned a DD name. Similarly, when the data set no longer needs to be accessed, the data set and DD name must be released (for more information, see command FREE in this table). This DD name is local to the script that creates it. |
CLOSEFILE ddname |
Closes sequential data set ddname. ddname is any DD name consisting of a constant, KSL variable, or AutoEdit variable. |
FREE DD ddname |
Dynamically frees the data set allocated to the specified DD name. (The DD name is assigned by command ALLOC.) Activate this command when a data set no longer needs to be accessed by the script. |
GETFILE ddname INTO varname
|
Stores in the specified variable the contents of the next record in the sequential file referenced by ddname, where
|
Opens sequential data set ddname for access.
|
|
PUTFILE ddname FROM varname |
Writes the contents of variable varname in the next record of the sequential file referenced by ddname.
|
Assigns the appropriate value to the variable name. This command is used to create (set) a global AutoEdit variable. expression may contain a KSL variable. This command is only available if Control-O is installed at your site. Global AutoEdit variables can only be used when the Control-O monitor is online. For further information, see the DO SET statement in the Control-O User Guide. |
|
Assigns the value of the expression to the variable name. This command is used to create (set) a Local AutoEdit variable. expression may contain a KSL variable. |
|
SETVAR varname CURSOR length |
Assigns extracted text to variable varname. This command is used to create (set) variables.
|
SETVAR varname DATA{‘textstring’|expression} |
Assigns a text string to variable varname. This command is used to create (set) variables.
|
SETVAR varname SCREEN from-line from-col length |
Assigns extracted text to variable varname. This command is used to create (set) variables.
Variable value is determined by the screen contents at a specific screen position. The screen position is specified by:
|
SHOUT TO destination [URGENCY urgency] TEXT {textstring|expression} |
Sends ("shouts") textstring to the specified destination.
|
VariablesLink copied to clipboard
KSL variables can be used to add flexibility to a KSL script. These variables are assigned using a KSL command (such as SETVAR) and are resolved during the run of the KSL script.
A KSL variable must start with % and can be 2 through 40 characters long. A blank designates the end of the variable name.
Note: The second character in a KSL variable name must not be a percent sign. KSL assumes that a variable beginning with %% is an AutoEdit variable. If a KSL script is to search for a prerequisite condition whose name begins with a single percent sign (%), KSL assumes it is a KSL user-defined variable and does not recognize the searched-for condition.
KSL variables are only accessible by the KSL script in which they are defined. A reference to the same variable in another command member (or in another invocation of the same command member) is totally independent and has no effect on the current member environment.
When an expression contains both KSL and special AutoEdit variables and functions, KSL variables are resolved first.
For more information about syntax and KSL variables, see Language Syntax.
Special KSL VariablesLink copied to clipboard
Some KSL variables are reserved by, and have a special meaning for, KSL:
Table 6 Special KSL Variables
Variable |
Description |
---|---|
%A1-%A9 |
Passes the specified arguments to a called script. The number corresponds to the position of the argument in command CALLMEM. The argument is replaced throughout the called script member at invocation time. |
%CALLRC |
Contains the return code specified in the RETURN command when returning from command CALLMEM. Also contains the return code from programs called by the CALL or EXEC commands. |
%FINDRC |
Provides the return code of the result of the last FIND. If the last FIND was successful, has a value of 0. If the last FIND was unsuccessful, %FINDRC has a value of 4. |
%MSG |
Specifies text assigned at script termination, which appears as a message in the job’s SYSLOG and the script execution listing. Only the value of variable %MSG at the script member issuing command END is displayed. |
%RC |
Supplies the return code of the script. The value at successful script termination is the condition code of the step. Valid values are: 0 through 4095. |
%SCRCOL |
Current column position of the cursor. |
%SCRLINE |
Current line position of the cursor. |