Substitution code
Format
S ; nonzero.substitute ; zero.substitute ; null.substitute
The S code substitutes one of three values depending on whether the data to convert evaluates to zero or an empty string, to the null value, or to something else.
If the data to convert evaluates to zero or an empty string, zero.substitute is returned. If the data is nonzero, nonempty, and nonnull, nonzero.substitute is returned. If the data is the null value, null.substitute is returned. If null.substitute is omitted, null values are not replaced.
All three substitute expressions can be one of the following:
- A quoted string
- A field number
- An asterisk
If it is an asterisk and the data evaluates to something other than zero, the empty string, or the null value, the data value itself is returned.
Example
Assume a BASIC program where @RECORD is:
AFBFCVD
- Statement
- Output
- PRINT OCONV("x","S;2;'zero'")
- B
- PRINT OCONV("x","S;*;'zero'")
- x
- PRINT OCONV(0,"S;2;'zero'")
- zero
- PRINT OCONV('',"S;*;'zero'")
- zero