Substitution Conversion (S)

Substitution Conversion (S;value1;value2)

Top  Previous  Next

 

The S (substitution) conversion code allows an application to handle zero or null data items as a special case.

 

The full format of this conversion code is

 

S;value1;value2

 

The S code returns a value determined by value1 if the source data is not zero or null, or the value determined by value2 if the source data is zero or null.

 

The value1 and value2 items may be:

A number specifying the field from @RECORD (the current record being processed in a query) to be returned. A value of zero returns the content of @ID.

A literal string enclosed in single quotes, double quotes or backslashes.

An asterisk indicating that the original data is to be returned.

 

If either value is omitted, it defaults to a null string.

 

 

Examples

 

A file has a date field that contains zero when it is not significant. Using a date conversion would return this as 31 Dec 1967. The S conversion code could be used to replace the zero by a null string before applying the date conversion. The dictionary conversion code field could be

S;*;''VMD4DMY

 

 

The following table shows a variety of conversions for a data record of "F1FMF2" and a record id of "ID".

 

Conversion

Data

Result

S;1;2

0

F2

S;1;2

 

F2

S;1;2

5

F1

S;1;2

XX

F1

S;*;'ZZ'

0

ZZ

S;*;'ZZ'

2

2

S;0

0

 

S;0

1

ID

S;;0

0

ID