CVI
 
Converts an four byte string to an integer variable

Syntax
Usage

result = CVI( str )

Parameters

str
A String exactly four bytes in length with a binary copy of an integer variable stored in it.

Return Value

An Integer variable to copy the binary copy of a integer to.

Description

Returns a 32 bit Integer value using the binary data contained in a string that is exactly four bytes in length. An integer value of zero (0) is returned if the string is not exactly four bytes in length.

CVI is used to convert 4-byte-strings created with MKI.

This function can also be used to convert 32 bit integer values from a memory or file buffer without the need for a [[KeyPgType ]] structure. However, just as with the type structure, special care should be taken when using CVI to convert strings that have been read from a buffer. The CVI and MKI functions are processor dependent. That is, they will return different results depending on the endianness of the processor.

Example

Dim a As Integer, b As String
a=4534
b=MKI(a)
Print a, CVI(b)
Sleep


Dialect Differences

  • In the -lang qb dialect, CVI expects a 2-byte-string, since a QB integer is only 16 bits. Only the first two bytes of the string are used, even if the string happens to be longer than two bytes.

Differences from QB

  • In QB an error occurs if the string passed is less than two bytes in length.

See also