1. Home
  2. CONCATENATE directive

CONCATENATE directive

Concatenates and truncates lines (units) of text structures; allows the case of letters to be changed.

Options

NEWTEXT = text Text to hold the concatenated/truncated lines; default is the first OLDTEXT vector
CASE = string token Case to use for letters (given, lower, upper, changed); default give leaves the case of each letter as given in the original string

Parameters

OLDTEXT = texts Texts to be concatenated
WIDTH = scalars or variates Number of characters to take from the lines of each text, a negative value takes all the (unskipped) characters other than trailing spaces; if * or omitted, all the (unskipped) characters are taken
SKIP = scalars or variates Number of characters to skip at the left-hand side of the lines of each text, a negative value skips all initial spaces; if * or omitted, no characters are skipped

Description

The CONCATENATE directive joins lines of several texts together, side by side, to form a new text. You can specify the identifier of this text by the NEWTEXT option, in which case it need not already have been declared as a text. If you do not specify NEWTEXT, Genstat places the new textual values into the first text in the OLDTEXT parameter list (replacing its existing values).

The texts to be concatenated are specified by OLDTEXT; they should all contain the same number of lines, unless you want to insert an identical series of characters into every line of the new text: a series of characters that is to be duplicated within every line can be specified either as a string, or in a single-valued text.

If you give a variate in the SKIP list, then it must contain a value for each line of the text in the OLDTEXT list; the value indicates the number of characters to be omitted at the beginning of that line. Alternatively, you can give a scalar if the same number of characters is to be omitted at the start of every line. Similarly the WIDTH parameter specifies how many characters are to be taken, after omitting any initial characters as specified by SKIP.

CONCATENATE also provides easy ways of removing spaces at the beginning or the end of strings. A negative value of the SKIP parameter deletes all the spaces at the start of a string, while a negative value of the WIDTH parameter deletes all the spaces at the end of a string.

The CASE option enables you to change the case of letters. By default, CASE=given to leave the case of each letter as given in the existing text. To change all letters to upper case (or capitals) you can put CASE=upper, or CASE=lower to change all letters to lower case. Alternatively, CASE=changed puts lower-case letters into upper case, and upper-case letters into lower case!

Options: NEWTEXT, CASE.

Parameters: OLDTEXT, WIDTH, SKIP.

Action with RESTRICT

CONCATENATE takes account of restrictions on any of the vectors that occur in the statement. If more than one vector is restricted, then each such restriction must be the same. The values of the units that are excluded by the restriction are left unchanged.

See also

Directives: TEXT, EDIT, TXBREAK, TXCONSTRUCT, TXFIND, TXPOSITION, TXREPLACE.

Procedure: APPEND, SUBSET, STACK, UNSTACK.

Functions: CHARACTERS, GETFIRST, GETLAST, GETPOSITION, POSITION.

Commands for: Calculations and manipulation.

Example

" Example CONC-1: Use of the CONCATENATE directive"

TEXT [VALUES=' 1. Adams',' 2. Baker',' 3. Clarke',' 4. Day',' 5. Edwards',\ 
             ' 6. Field',' 7. Good',' 8. Hall',' 9. Irving','10. Jones'] Name
TEXT [VALUES='B.J.','J.S.','K.R.','A.T.','R.S.',\ 
             'T.W.','S.I.','D.M.','H.M.','C.C.'] Initials

" form Fullname with number, name & initials "
CONCATENATE [NEWTEXT=Fullname] OLDTEXT=Name,' ',Initials
PRINT Fullname ; JUSTIFICATION=left

" form Fullname with initials & name "
CONCATENATE [NEWTEXT=Fullname] OLDTEXT=Initials,Name ; SKIP=*,3
PRINT Fullname ; JUSTIFICATION=left
Updated on March 8, 2019

Was this article helpful?