The function converts any numerical value to a STRING with freely defined format.
i_sFormat = '[B][S][PPPP][.][FFFF][A][aa]'
Numerical value (i_lrInput) |
Defined format (i_sFormat) |
Result STRING[80] |
---|---|---|
12.3456 |
‘10#00.000000L15’ |
‘12.345600 ‘ (6 spaces at the right-hand side) |
The format is specified in the input variable i_sFormat as follows:
Placeholder |
Description |
---|---|
[B] |
Sets the base of the number representation:
If no value is given for ‘B’, ‘10’ is used as default value. |
[S] |
Represent the mathematical sign. If a base is entered, then the mathematical sign representation must also be specified. Otherwise, this entry is dispensed with and ‘#’ is used as default. As a basic principle, a minus sign precedes negative values, independent of the format specification. In other respects, the following options exist for formatting:
|
[PPPP] |
Each ‘P’ character before the decimal point represents a place preceding the decimal point in the output. This is used to set the minimum number of characters that are reserved for the whole number component. Additionally this defines the content for the output when the numerical representation is shorter than the format string expects. If ‘P’ is a space, then a space is inserted at that position. If ‘P’ is zero, then a zero is inserted. Using this portion of the format input you can implement leading zeros or, in other words, you can set the decimal point to a fixed position from the left edge of the output string. If only a zero is specified, all places preceding the decimal point of the transferred LREAL are converted to a string. For example:
|
[.] |
The decimal point is only required when fractional characters are desired. |
[FFFF] |
The ’F’ signs following the decimal point determine the number of spaces following the decimal point in the output. Each ’F’ represents one position following the decimal point. If the input value has more positions following the decimal point than the format provides for, the remainder is deleted. If it has fewer, then it is filled up according to ’F’. If ’F’ is an empty space, then an empty space is put into that position. If ’F’ is zero, then a zero is put there. If ’F’ is an underline, nothing is entered. This input is used to either fix the number of positions after the decimal point or to determine the distance of the decimal point from the right edge. For example:
|
[A] [aa] |
‘A’ an ‘aa’ determine if the output has a fixed total length and if it is to be left or right justified or centered. Possible values are ‘L’ for left justified, ‘R’ for right justified; or ‘C’ for centered. The desired length of the output is determined by ‘aa’. If the output has more characters than specified, the value to the right is filled out with empty spaces so that the numbers are displayed according to ‘A’. If no adjustment is desired, simply do not specify any ‘A’ or ‘aa’ in the format string. But if one of the two values is specified, then the other must be specified as well. For example:
|
Input |
Data type |
Description |
---|---|---|
i_sFormat |
STRING[80] |
Formatting the output. |
i_lrInput |
LREAL |
The value to be formatted. |
Output |
Data type |
Description |
---|---|---|
q_etResult |
Provides diagnostic and status information as an enumeration value. |
|
q_sResultMsg |
STRING [80] |
Provides additional diagnostic and status information as a text message. |