Domain: PROCEDURE
Command description
The SELECT-VARIABLE-ELEMENTS command displays the elements of an S variable (list variable) on the screen and writes any elements selected from these to another S variable. The screen output can be structured by means of headings for user guidance. Scrolling is implemented in a similar way as in guided dialog under SDF; function keys can be assigned using the /MODIFY-SDF-OPTIONS command.
Layout of screen output
The first line of the screen is an underlined heading, followed by a line with column titles indicating the type of element values displayed in the respective column. The two text lines are defined by means of the command operands HEADER-LINE and TITLE.
Each subsequent line contains the value(s) of a single element. Each line starts with a check field “( )”, followed by a blank and up to 75 characters. The column spacing can be defined implicitly by means of the LENGTH operand (default = ). See the example given at the end of this command description.
Selecting a line
An element (line) is selected by entering any character between the parentheses in the check field. The command can define that an element containing this character is to be automatically added to the output variable.
Format
SELECT-VARIABLE-ELEMENTS |
<composed-name 1..255>(...) SELECTION-CODE = *NO / *YES(...) *YES (...) LENGTH = 1 / <integer 1..75> ,HEADER-LINE ,MESSAGE ,DISPLAYED-ELEMENTS = <composed-name 1..255>(...) LENGTH
|
Operands
FROM-VARIABLE = <composed-name_1..255>
Name of the S variable (input variable, list variable) whose elements are to be displayed.
TO-VARIABLE = <composed-name_1..255>(..)
Name of an S variable (output variable) to which the selected elements are to be written. Any existing variable of that name will be overwritten.
SELECTION-CODE=
Specifies whether the character used for selecting is to be written to the output variable.
SELECTION-CODE= *NO
The character used for selecting is not to be written to the output variable.
SELECTION-CODE= *YES (...)
The variable element SELECTION-CODE is automatically added to the output variable and filled with the value entered in the mark column. This value has variable length, if it is shorter than the mark column it isn't filled up.
If the input variable is a simple list (integer, Boolean or string), the element VALUE is also added to the output variable; the selected list element will be written to this element.
The output variable must be declared as a dynamic structure; otherwise, the command will be rejected.
LENGTH = 1 / <integer 1..75>
Length of the selection code value, hence the width of the mark column. This value implies a limitation of the length of the selection lines, i.e. one character less per additional mark column character. This specification is only meaningful if the selection code is processed as output value.
The NULs (0x00) between the characters input in the selection column are suppressed i.e. the characters separated by NULs are concatenated together. The length of the value of the returned SELECTION-CODE is the length of the not-NUL input character string.
HEADER-LINE = *NONE / <c-string_1..80>
Defines the heading (text line) for screen output. Up to 3 lines can be displayed. The number of lines in the selection list depends on the number of lines in the title and message parts, i.e. one line less per additional title and message line. The text is presented such as to avoid the cut of the small words on 2 lines hence the presented text can be longer than the specified value. If the presented text exceeds 3 lines, it is truncated with "...".
MESSAGE=*NONE/<text 1..240 with-low>
Message which is displayed in the first menu below (in the last 3 lines). The message is no longer displayed after the screen has been sent.
Up to 3 lines can be displayed. The number of lines in the selection body depends on the number of lines in the title and message parts, i.e. one line less per additional title and message line. The text is presented such as to avoid the cut of the small words on 2 lines hence the presented text can be longer than the specified value. If the presented text exceeds 3 lines, it is truncated with "...".
DISPLAYED-ELEMENTS
Designates one or more elements of the input variable and determines what will be displayed on the screen.
Only first-level values will be output for structure elements.
DISPLAYED-ELEMENTS = *STD
This specification has a different effect for simple and for complex variables:
Simple variable:
All element values will be output, one element value per line.
Complex variable (structure):
Only the element value of the first structure element will be output in each case, one element value per line.
DISPLAYED-ELEMENTS = <composed-name_1..255>(...)
Names of one or more variable elements whose values are to be output, where all the values of an element will be written in the same line. Element values will be output in the order in which they are specified in the operand list. The elements must be of data type “integer”, “Boolean” or “string”.
LENGTH = *BY-VALUE / <integer_1..76>
Output length of element values. The sum of all element values output to a line must not exceed 75 characters, including spaces between individual values. Lines exceeding
75 characters are truncated. Specifying *BY-VALUE means that the (implicit) length of the element value will be used; maximum 75 characters.
TITLE = *BY-ELEMENT-NAME / <c-string_1..76>
Text indicating the element value displayed in that column; the value specified with LENGTH=.... determines the maximum length. When LENGTH=*BY-VALUE is defined, the specified text is truncated if it exceeds the maximum length. Specifying *BY-ELEMENT-NAME means that the element name will be used as a title.
Command return codes
(SC2) | SC1 | Maincode | Meaning/Guaranteed messages |
0 | CMD0001 | No error | |
1 | CMD0202 | Syntax error | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
64 | SDP0091 | Semantic error Guaranteed messages: SDP1120, SPD1121, SPD1122 | |
64 | SPD0259 | Operation aborted: selection ignored | |
130 | SDP0099 | No further address space available |
Example
Section of a procedure (delete/display files):
The S variable OPS contains output from the SHOW-FILE-ATTRIBUTES command. Subelements of this variable (F-NAME, F-SIZE, CRE-DATE) that are selected by means of the SELECT-VARIABLE-ELEMENTS command are displayed on the screen. Some elements are then selected and marked with either “d” or “s”; the elements are transferred to the S variable SELECTED together with the character used for marking. The (small) procedure shown below the sample screen deletes any files marked with “d” and displays the contents of any files marked with “s”.
/declare-variable OPS(type=*structure),multiple-elements=*list /declare-variable SELECTED(type=*structure),multiple-elements=*list /declare-variable STRUC(type=*structure) /execute-cmd (show-file-attributes *all,select=*by-attributes(- / size=*interval(from=500),information=*all)),- / structure-output=OPS,text-output=*NONE /select-variable-elements from-variable=OPS,- / ,to-variable=SELECTED(selection-code=*yes),- / header-line='Please select files to be deleted (d) or shown (s)',- / displayed-elements=(F-NAME(LENGTH=54,TITLE='File name'),- / F-SIZE(TITLE='Size'),CRE-DATE)
Please select files to be deleted (d) or shown (s) -------------------------------------------------------------------------------- File name Size CRE-DATE (d) A1 501 12-04-2007 (d) A2 502 12-04-2007 ( ) A3 503 12-04-2007 ( ) A4 503 12-04-2007 (s) A5 504 12-04-2007 ( ) A6 505 12-04-2007 (s) A7 506 12-04-2007 ( ) A8 507 12-04-2007 ( ) A9 508 12-04-2007 ( ) B1 509 12-04-2007 (d) B2 510 12-04-2007 -------------------------------------------------------------------------------- NEXT= + *EXECUTE or *CANCEL or *NONE or *ALL or + -------------------------------------------------------------------------------- LTG TAST
/for STRUC=*list(SELECTED) / struc.selection-code = upper-case(struc.selection-code) / if struc.selection-code == 'D' / delete-file &(STRUC.F-NAME) / end-if / if struc.selection-code == 'S' / show-file &(STRUC.F-NAME) / end-if /end-for