Concantenate. DORIC 9.65, INFO-Text software
Реклама
Реклама
CONCATENATE
CON
CATENATE DF_item [FROM] DF_item_1 system_item system_item_1 system_variable system_variable_1 string syntax cont’d
[+] [,source_item2,...,source_item15]
or
DF_item system_item system_variable
=
DF_item_1 system_item_1 system_variable_1 string
assigns a value to a data file item, system item, or system variable
(target items) by combining the values of from 1 to 15 data file items, system items, system variables, or strings (source items).
arguments
DF_item | system_item | system_variable the target item. A value can be assigned to any of these items or variables.
[FROM] is used only for documentation or ease of understanding.
DF_item_1 | system_item_1 | system_variable_1 |
string the source item.
DF_item is an INFO data file item.
system_item_1 is an INFO system item.
system_variable_1 is an INFO system variable.
string is a character string enclosed within single quotes.
INFO Reference Manual Commands 105
CONCATENATE commandless syntax
[+] directs INFO to place a space before the next source item. INFO does not leave the space if the previous source item has a value of all blanks.
[,source_item2,...,source_item15] when you give more than one source item, you must separate them with commas (or current delimiter). Valid items are the same as for the source item.
It is not necessary to include the command name
CONCATENATE in the statement.
CONCAT $CHRIO FROM ‘INFO9.6’ ‘IS’, ‘AVAILABLE’, ‘NOW’ can be coded as
$CHRIO=‘INFO9.6’, ‘IS’, ‘AVAILABLE’, ‘NOW’
notes
n
The results of concatenating into a B-, F-, or P-type data file item, system item, or system variable are unpredictable.
n
If you wish to produce a space in the resulting target item in the position after a string source item, and if the string is followed by a data file item, you must include the space as the last character of the string value. To produce a space in the resulting target item in the position between two concatenated strings, you must include the space as either the last character of the first string or the first character of the second string.
n
When a CONCATENATE is performed from an item on a related file where there is a ‘no-match’, by default the target item is blank-filled. This can be avoided by setting the system variable $MOVFLG to 1. If this is done, the target item will be left intact if the source item has not been matched; a ‘no-match’ condition for any of the source items with $MOVFLG set to 1 will suffice to activate this option.
106 Commands INFO Reference Manual
CONCATENATE discussion
The CONCATENATE command operates according to the following rules:
1) CONCATENATE ignores trailing blanks in source items.
2) Source items that are strings are used exactly as specified.
3) If the target item is a C-type item and is not wide enough to hold the resulting concatenated value, the result is truncated on the right.
4) If the target item is wider than the resulting string, the target item is blank padded on the right.
5) INFO allows you to use the CONCATENATE command to build ASCII numeric string values (INFO numeric item types other than B, F, or P). If the target item is an ASCII numeric string value, the following considerations apply: a) The length of the target item must equal the sum of the lengths of all source items specified.
b) The source item(s) must be formatted appropriately for the target item. For example, if the target item is an I-type item, source items cannot contain embedded blanks; if the target item is an N-type item, the concatenation of the source items must result in a decimal point that is properly located in the target item.
You can control the concatenation process for C-type items using the WD (width) unary arithmetic operator (see
'Building expressions’). Using the WD operator, you can determine the width of a C-type item, excluding trailing blanks, and perform subsequent operations based on whether that length is appropriate for the target item.
INFO Reference Manual Commands 107
CONCATENATE example
In this example, the item FIRST-NAME is not included if it causes the target item ($CHR2) to exceed its maximum length. The plus sign (+) is used to leave a space between the concatenated source items, if the preceding source item is not blank.
10000 PROGRAM SECTION ONE
10001 FORMAT $CHR2,20,C
.
.
.
20000 PROGRAM SECTION TWO
.
.
.
20004 CALC $NUM1 = WD FIRST-NAME + WD LAST-NAME + WD TITLE
20005 IF $NUM1 LE 20
20006 CONCATENATE $CHR2 FROM TITLE +,FIRST-NAME +,LAST-NAME
20007 ELSE
20008 CONCATENATE $CHR2 FROM TITLE +,LAST-NAME
20009 ENDIF
.
.
.
108 Commands INFO Reference Manual
Скачать
Реклама