Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Futurebasic/Language/Reference/cvi

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

CVI function CVI Function ✔ Appearance ✔ Standard ✔ Console Syntax var& = CVI(string$) Description This function converts the bytes in string$ into an integer value which has the same internal bit-pattern that string$ has. If string$ consists of 4 or more bytes, only its first 4 bytes are considered. If string$ consists of 1, 2 or 3 bytes, then CVI(string$) returns an 8-bit, 16-bit or 24-bit integer, respectively. If string$ is a null string, then CVI(string$) returns zero. This function is useful for finding the integer form of such things as file types, creator signatures and resource types. For example: ft$ = "TEXT" theType& = CVI(ft$) After executing the above, theType& is then suitable for passing to a Toolbox routine which requires a file-type parameter. theType& will also have the same value as the integer constant _"TEXT". The size (in bytes) of the value returned by CVI depends on the length of string$. It does not depend on the current setting of DEFSTR BYTE/WORD/LONG. Therefore, if you want to assign the return value of CVI to a short integer variable, you must make sure that string$ is not longer than 2 bytes; otherwise, you'll get an unexpected value in your short integer variable. Similarly, if you want to correctly assign CVI's return value to a byte variable, you should make sure that string$ is not longer than 1 byte. The MKI$ function is the inverse of CVI. Note, however, that the output of MKI$ does depend on the current setting of DEFSTR BYTE/WORD/LONG. Note If string$ is 1 byte long, then CVI(string$) returns the same value as ASC(string$). See Also DEFSTR; LONG; WORD; BYTE