CONVERT
General Forms :
1. CONVERT alpha_variable TO numeric_receiver
2. CONVERT numeric_expression TO alpha_receiver, (picture)
Where:
The CONVERT statement is used to convert an alpha variable to a numeric receiver or a numeric value to an alpha receiver string.
Alpha variable to numeric receiver
This first form of the CONVERT statement converts the contents of an alpha variable to a numeric receiver. The contents of the alpha variable must be a valid ASCII representation of a number, otherwise a recoverable error will occur.
Example:
CONVERT total$ TO new_total
Numeric expression to Alpha receiver
The second form of the CONVERT statement converts a numeric expression into an alpha receiver in the format specified by the picture.
The picture specifies exactly how the numeric value is to be converted. Each character in the picture corresponds to a character in the resulting alpha receiver. The picture is made of digit selector characters `#' to signify a single digit, optional plus signs `+, ++', minus signs `-, --', decimal points `.', and exponent signs `^' are used to specify sign, decimal point position, and exponential format. The picture can be put into two separate classifications, fixed point `###.##' and exponential `#.##^^^^'. The picture formats the numeric values based on the following rules:
Example:
field = 13579.2468
CONVERT field TO total1$,(#####.#####)
.Edit1.text$ = total1$
Syntax examples:
CONVERT 159.9 TO tmp$,(###.##)
CONVERT tap$ TO new_number
CONVERT STR(actual$,4,6) TO new_number
CONVERT old TO balance$,($###,###.###--)
CONVERT old TO FLD(record$.entry$),(picture1$)
See also: