CVL

From QB64 Wiki
Revision as of 14:19, 11 September 2017 by imported>SMcNeill (style guidelines)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The CVL function decodes a 4-byte STRING generated by MKL$ (or read from a file) to LONG numeric values.


Syntax

result& = CVL(stringData$)


Description


Examples

Example 1: 4 byte ASCII character strings show how CVL multipliers convert MKL$ values into a 4 byte LONG value.

PRINT CVL(CHR$(1) + STRING$(3, 0)) 'ASC(CHR$(1)) * 1 = 1 PRINT CVL(CHR$(0) + CHR$(1) + STRING$(2, 0)) 'ASC(CHR$(1)) * 256 = 256 PRINT CVL(STRING$(2, 0) + CHR$(1) + CHR$(0)) 'ASC(CHR$(1)) * 256 * 256 = 65536 PRINT CVL(STRING$(3, 0) + CHR$(1)) 'ASC(CHR$(1)) * 256 * 256 * 256 = 16777216


Example 2:

FIELD #1, 4 AS N$, 12 AS B$... GET #1 Y& = CVL(N$)

Explanation: Reads a field from file #1, and converts the first four bytes (N$) into a long integer value assigned to the variable Y&.
Since the representation of a long number can use up to 10 ASCII characters (ten bytes), writing to a file using MKL$ conversion, and then reading back with the CVL conversion can save up to 6 bytes of storage space.


See also



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page