CVBYT, CVCUR, CVCUX, CVD, CVDWD, CVE, CVI, CVL, CVQ, CVS and CVWRD functions

Purpose

Convert string data to numeric form.

Syntax

bytevar?         = CVBYT(variable [, offset])

curvar@          = CVCUR(variable [, offset])

cuxvar@@         = CVCUX(variable [, offset])

doublevar#       = CVD  (variable [, offset])

doublewordvar??? = CVDWD(variable [, offset])

extendedvar##    = CVE  (variable [, offset])

integervar%      = CVI  (variable [, offset])

longintvar&      = CVL  (variable [, offset])

quadintvar&&     = CVQ  (variable [, offset])

singlevar!       = CVS  (variable [, offset])

wordvar??        = CVWRD(variable [, offset])

Remarks

The CVx functions return a number corresponding to a binary pattern stored in a string value.  The MKx functions are complementary to the CVx functions.  Do not confuse these functions with the VAL function, which converts a number stored as a printable text string (such as "123.45") into a numeric expression.

The CVx functions allow retrieving values beyond the first byte of the input string variable, where offset indicates at what position in the string the function should retrieve value.  variable may be either a User-Defined Type or a string.

For example: "Value& = CVL(x$, 3)" would extract the 3rd through 6th bytes of x$ and convert these 4 bytes to the corresponding Long-integer value.  In this example, x$ must be at least 6 bytes long.

Function

Variable

Converts to

CVBYT

1-byte string

Byte

CVCUR

8-byte string

Currency

CVCUX

8-byte string

Extended-currency

CVD

8-byte string

Double-precision float

CVDWD

4-byte string

Double-word

CVE

10-byte string

Extended-precision float

CVI

2-byte string

Integer

CVL

4-byte string

Long-integer

CVQ

8-byte string

Quad-integer

CVS

4-byte string

Single-precision float

CVWRD

2-byte string

Word

Expressions involving Numeric Equates and conditional compilation (#IF) may also include the CVQ function.  This allows you to easily assign numeric values to an equate, based upon a meaningful mnemonic.  In this context, the CVQ expression is limited to a length of eight bytes.  For example:

%Mode  = CVQ("DEBUG")

%Style = CVQ("Cool")

See also

MKI$ and associated functions