Validating logical expressions
Quick reference
To evaluate a logical expression, type:
r [/err_code/] (logical_expr) [$message$]
More information
The require statement can be used to evaluate a logical expression. If the expression is false, the record will be dealt with according to the specified (or default) action code. If the expression is true, the program continues with the next statement.
This type of require also has four parts, two of which are optional:
1 The word require or the letter r followed by a space.
2 An optional action code enclosed in slashes.
3 A logical expression enclosed in parentheses.
4 An optional error text enclosed in dollar signs.
Items 1, 2 and 4 are as described in
Validating logical expressions.
For more information about logical expressions, see
Expressions.
Example
r /3/ (c133'4' .and. c140n'5') $Cols 33/40 incorrect$
says that c133 must contain a ‘4’ and c140 must not contain a ‘5’. If one or other or both expressions are false, Quantum prints the record out with the message ‘Cols 33/40 incorrect’ and rejects it from the tables.
This type of require statement is often used to check the number of codes present in a column or group of columns. For example, if the questionnaire specifies that the respondent should name no more than three products in their answer, you might write:
r (numb(c139).le.3)
causing any record in which column 39 is multicoded with more than 3 codes to be printed and rejected. This statement has no error text, so any records printed will be followed by the require statement itself.
See also