Top  Previous  Next


The OCONV() function performs output conversion. Data is converted from its internal representation to the external form. This function is typically used to convert data for display or printing. The OCONVS() function is identical to OCONV() except that it works on each element of a dynamic array, returning the result in a similarly delimited dynamic array.





OCONV(expr, conv.spec)

OCONVS(expr, conv.spec)




exprevaluates to the data to be converted.


conv.specevaluates to the conversion specification. This may be a multivalued string containing more than one conversion code separated by value marks. Each conversion will be carried out in turn on the result of the previous conversion.



The OCONV() function converts the value of expr to its external representation according to the conversion codes in conv.spec.


If conv.spec is a null string, OCONV() returns expr as its result.


The OCONV() function sets the STATUS() function value to indicate whether the conversion was successful. Possible values are


0Successful conversion.
1Data to convert was invalid for the conversion specification.
2The conversion code was invalid.


Conversions that result in a non-zero STATUS() value return the string that failed to convert as the function result. For an OCONV() function where conv.spec is not multivalued or where the first stage of a multiple conversion fails, the function would return expr. If one or more stages of a multivalued conv.spec have been completed, the returned value is the result of the last successful stage.





DT = 14992



The above example converts a date from internal format as a value 14992 to its external form as 16 JAN 09.



DT = 14992VM14000

S = OCONVS(DT, 'D2')


The above example converts a multivalued list of internal format dates to an equivalent multivalued list of external form dates. Variable S is set to

16 JAN 09VM30 APR 06



See also:

Conversion codes, ICONV()