Cvi Function

Purpose

Converts four characters in a string to a 32 bit integer.

Syntax

int32 = Cvi(a$ [,offset% = 1])

Description

Cvi takes four characters starting at offset in a string as a number. Cvi(a$) is equivalent to LPeek(V:a$). Cvi returns 0 if the string length is less than four.

Example

OpenW 1

Print Cvi("Hello GFA")

// prints 1819043144

Print Cvi(Mki$(24))

// Prints 24

Local a$ = Mki(100, 200, 300, 400)

Print Cvi(Mid$(a$, 1)), Cvi(Mid$(a$, 5)), Cvi(Mid$(a$, 9)) , Cvi(Mid$(a$, 13))

// Prints 100 200 300 400

Print Cvi(a$ , 5) // prints 200

Remarks

The order of the bytes depends on the processor. For 80x86/8 or 8088 processors LSB (least significant byte) is converted first and MSB (most significant byte) is converted last.

Cvi() is the reverse function of Mki$().

Cvi() is the same as Cv4() and Cvl()

See Also

Asc(), Cvl(), Cvs(), Cvd(), Chr$(), Mki$(), Mkl$(), Mks$(), Mkd$()

{Created by Sjouke Hamstra; Last updated: 27/09/2014 by James Gaite}