Dynamic Field Separators

To simplify conversions and integration with other products, it is often desirable to support multiple field separator characters. PxPlus provides both “multiple field separators” and a “dynamic field separator option” that will automatically attempt to determine what the field separator is for a string.

Areas Affected:

Both of these capabilities only relate to the READ DATA FROM, ARG, and KGN functions where there is no way of determining the field separator being used. Normal file READ and WRITE operations will use the field separator as defined in the file header or the SEP system variable.

Defining multiple separator characters or enabling Dynamic separators will not affect file I/O.

Enabling Dynamic Separators:

Enable the use of Dynamic separators by turning on the '+S' system parameter. While this option is enabled the READ DATA FROM directive along with the ARG( ) and KGN ( ) functions will all utilize the dynamic separator logic, in order to attempt to determine the field separator instead of using the default SEP system variable (usually $8A$).

The dynamic separator logic will scan the data and look at the last non-null byte. If this last non-null byte is the system standard field separator, less than a space, or equal to hex 7F it will be considered the field separator for the data and all field parsing will use it to delimit the fields. This will allow for the automatic determination of field separators such as TAB ($09$) and Linefeed ($0A$).

This feature is only active if the '+S' system parameter is enabled.

Multiple Field Separators:

By default, PxPlus will only recognize the SEP system variable as the default when trying to parse fields out of a sting. In some instances, it may be desirable to specify multiple field separators where any one of a list of known characters could be the field separator.

Using the DEF SEP(<string>) directive allows the programmer to define a list of potential field separators. For example, DEF SEP($8A0A$) tells the system to accept either an $8A$ or $0A$ as the field separator. When issuing the DEF SEP directive the first character will become the system DEFAULT field separator.

Note that only ONE separator exists at a time when parsing the data. That is when the data is processed in READ DATA FROM directive; it is first scanned to determine which, if any, of the field separator characters exist in the data. This scan is done initially with the first character in the separator list and if not found in the data, the second character is checked and so on.

The currently defined field separators can be retrieved by accessing SEP(*).