*&var= Assigning Procedure Variables
*&var1 = [ &var2 | [C|L|X]'string' ] [ .&var3 | .[C|L|X]'string' ] ...
The value following the '=' sign will be asigned to the procedure variable &var1. A procedure variable can also be assigned a value calculated by an aritmetical operation on two constants or other variables. The syntax of such a construction is described below.
&var2 &name [ ( [s] [, l] ) ]
Value or substring of a CFS procedure variable.
&name Name of a CFS procedure variable or %PTR.
%PTR can be used with regard to positions of search string results returned by previous *IF %OUT=... or *ON %OUT=... statements.
%PTR(1,l) represents, for example, a string that is l byte long, occuring after the string found with the %OUT string. For a full example of the usage of %PTR, see page 19-.
%PTR0(1,l) represents the first byte of the search string, or the first byte of the first of a sequence of search strings linked with *.
s optional specification of the start column for a substring of the variable. ( 1 <= s < 80 ). Negative columns can also be specified for %PTR.
%PTR(s,l) indicates a string l bytes long, beginning at position s-1 behind that position at which the string found by %OUT begins.
%PTR(-s,l) indicates a string l bytes long, beginning s positions before the string found by %OUT.
Standard: s = 1.
Example:
Text to be searched: 123abc---------xyz789
*IF %OUT='abc'*'xyz'
*&VAR=%PTR(1,3) --> &VAR='789'
*&VAR=%PTR(-3,4) --> &VAR='-xyz'
*&VAR=%PTR0(1,4) --> &VAR='abc-'
*&VAR=%PTR0(-3,4) --> &VAR='123a'
l optional specification of the substring length. ( 1 <= l <= 80 ).
Standard: l = Full length of the variable.
[C|L|X]'string' constant string. C'string' is equivalent to 'string'. L'string' will result in the lowercase letters in string not being converted to uppercase. Apostrophes within a string must be entered twice ('').
If the variable is assigned a numerical value, the apostrophes can be omitted: *&var=[-]num
Examples: *&N=1, *&COUNTER=-10
.&var3 Multiple substrings can be suffixed to the variable in the form .&var | .'string'. A fullstop must be specified as a separator before the second and later substrings.
Notes:
The name of a procedure variable that has not yet been declared can be specified for &var1. The variable will automatically be created, and can be used immediately.
A Procedure variable can also be assigned a value captured from a Display file. For further information, see the W (Write) command on page 8- and the S,..=W command (Search and Rewrite) on page 8-.
*&var1 = [ &var2 | value ] op [ &var3 | value ]
The result of the arithmetical calculation following the '=' sign will be assigned to &var1.
&var2 | &var3 Name of a CFS Procedure variable.
value numerical constant: [-] number.
op arithmetical operator:
+ | - | * | /
Notes:
The *RUN procedure statement can be used to perform complex operations, perhaps also including search conditions, on procedure variables. For further information, see page 19-.
If procedure variables are specified as arithmetical operands, these must contain numerical values ([-]number). An exception is the CFS-internal variable &DATE (yy-mm-dd). &DATE can be arithmetically linked by + or - to a numeric constant. The result is still a date.
If two values are divided, the result will be rounded. If an attempt is made to divide by zero, then the &var1 variable will not be assigned a value (equivalent to &var1='').
Examples:
*&T1='Connection 1: Application '
The specified character string will be assigned to variable &T1.
*IF &CON1 = '' &T1 = &T1.' not opened'
If Connection 1 has not been opened (contents of variable &CON1 = ''), the character string ' not opened' and the previous value of the variable &T1 will be concatenated.
*IF &CON1 -= '' &T1 = &T1.&CON1
If the CFS-internal variable &CON1 is not empty (''), i.e. if Connection 1 has been opened, then &T1 and &CON1 will be concatenated.
*&DZ = &DATE(7,2).'.'.&DATE(4,2).'.' .&DATE(1,2).' '
*&DZ = &DZ.&TIME(1,2).':'.&TIME(3,2).':'.&TIME(5,2)
A new variable &DZ will be constructed from the CFS-internal variables &DATE (yy-mm-dd) and &TIME (hhmmss), which will contain the following: 'dd.mm.yy hh:mm:ss'.
*&COUNT=&VAR1+1
The value in &VAR1 will be incremented by 1 and assigned to &COUNT.
*&VAR1=&VAR1-&N
The value in &VAR will be decremented by the value in &N.
*&D=&DATE+1
The variable &D will be assigned tomorrows date (dd-mm-yy).
Further examples can be found on page 20-.