<< Click to Display Table of Contents >> Navigation: Reference > Pre-processor > *SET |
The *SET command sets the value (or text) of an index. It takes one of these forms:
[*SET x = AE]
[*SET x = ’r;text’]
[*SET x = data set reference]
[*SET x = cellref]
[*SET index = %ITEMS($svar)]
[*SET index = %ITEMS($mvar)]
[*SET index = %ROWS(#table)]
[*SET index = %COLS(#table)]
[*SET index = %STARTYEAR]
[*SET index = %STARTMONTH]
[*SET index = %STARTDAY]
[*SET index = %STARTHOUR]
[*SET index = %STARTMINUTE]
[*SET index = %STARTSECOND]
[*SET index = %STARTSETUPPATH]
[*SET index = %STARTSETUPFILE]
These commands set the index to the total number of items in the svar or mvar, or rows or columns in the table not including the total rows or columns.
The value after the equals sign should not normally be surrounded by brackets.
Where a cellref is used leading and trailing blanks are ignored as are any zero decimal places, so 23.00 and 23. will both be accepted as the value 23. Any other characters apart from a leading + or - sign in the cell will cause the index value to be unset (NULL). You can use the *SKIP command to test for valid integer values.
The index to be set must not be in use as a current loop index. Its value need not be unset, however; all indices may be re-used as often as required.
Examples of valid *SET commands to set values:
[*set This=5]
[*set Count=Count+1]
[*set Line=(Product-1)*(10+Part)]
[*set Col = Start+1, Card = Begin+2, LastCol = Start+3]
[*set PartType=1.Part]
[*set Colour=ColourSet.3]
[*set Found=Loop.Type+1]
[*set Value=DBList.value]
See also [+index] which is equivalent to [*set index=index+1][index].
The *SET command can be used to set an index to text, for example:
[*set ThisPlace=’Paris’]
[*set ThatPlace=dsPlaces.lpThis]
[*set OtherPlace=’[dlPlaces.’Place’]’]
When an index is substituted, any valid whole number value will be used. The text is only used if it does not contain a valid number.
IMPORTANT: if the setting begins with a [ then it is assumed to contain a value so:
[*set ThatPlace=dsPlaces.lpThis]
[*set ThatPlace=[dsPlaces.lpThis]]
[*set ThatPlace=’[dsPlaces.lpThis]’]
The first and third commands can be used to set ThatPlace to text from [dsPlaces.lpThis]. The second command will fail unless [dsPlaces.lpThis] contains a valid number.
IMPORTANT: the text 15.0 is a valid whole number:
[*set Mytext=’15.0’]
[MyText]
The text output is 15 not 15.0.
VERY IMPORTANT: These functions will not work with PPONLY.
VERY IMPORTANT: See Compiler variable and table size references for important information about these functions:
[*set MyLength=%items($mysingle)]
[*set Rows=%rows(#5)]
[*set Cols=%cols(#5)]
The functions %START return the appropriate number for the date and time the run started.
The functions %STARTSETUP return the main CL script file path and name.
[*set yyyy=%startyear]
[*set mm=%startmonth]
[*set dd=%startday]
[*set hh=%starthour]
[*set mm=%startminute]
[*set ss=%startsecond]
date = [yyyy]/[0mm]/[0dd]
time = [0hh]:[0mm]:[0ss]
[*set path=%startsetuppath]
[*set file=%startsetupfile]
file = [path]\[file]