PCK() Function - Pack a Number
Syntax
PCK(num1,num2{,ERR=lineref})
Description
The intent of PCK() and UPK() is to allow compression of numeric values into a pseudo-binary form to save disk space. Because the BIN() and CHR() functions generate bytes that could be mistaken for field terminators (by the READ statement), another method was needed.
PCK() and UPK() are designed so that the packed strings do not contain field terminators. To be consistent with other implementations of PCK()/UPK(), the packed string for negative values will compare greater than a packed string for positive values. Also, a packed string for -2 will compare greater than a packed string for -1, though, numerically, -1 is greater than -2. PRO/5 does not necessarily use the same packed format as other BASICs; therefore, when converting existing data files to PRO/5, packed fields must be unpacked and then repacked under PRO/5.
Examples
>A$=PCK(12345678,4)
>PRINT A$
,BXn
>PRINT LEN(A$)
4
PRINT UPK(A$)
12345678