OCONV Function

The OCONV function may be used to convert an expression from internal format to external format, depending on the conversion code specified.

Format

OCONV(expr, code)

Parameter(s)

expr

An expression evaluating to the data to be converted.

code

An expression evaluating to a conversion code.

Description

Data is stored in internal format for consistency and flexibility. The OCONV function converts the data back to external format. For example, dates are generally kept as the number of days since December 31, 1967—so June 4, 1965 would be stored as -940, and OCONV(-940,"D") produces 4 JUN 1965.

To convert back from external format to internal format, use the ICONV function.

Conversion Codes

The conversion codes for OCONV correspond the codes used in INFO/ACCESS. Among the more common codes used in mvBASIC are:

D

Converts date to external format.

MT [H] [S]

Converts time to external format.

H

12-hour format

S

includes seconds

MX

Converts ASCII to hexadecimal representation.

T [DICT] filename ; c ; in-amc , out-amc

Translates from another file.

DICT

Uses the file dictionary.

filename

Name of file.

c

One of these action codes, specifying the action to take if the item or attribute does not exist:

C or O

If attribute or item is not found, returns original data; if file is not found, terminates abnormally.

V or I

If attribute, file or item is not found, terminates abnormally.

X

If attribute or item is not found, returns a null value; if file is not found, terminates abnormally.

in-amc

Attribute number for input conversion.

out-amc

Attribute number for output conversion.

Among the INFO/ACCESS codes that cannot be called by the OCONV function are F, A, and S.

Example

To convert data in the string STRING into hexadecimal format, the code might read:

STRING = OCONV(STRING, "MX")

See Also

Statement and Function Reference