Skip to content

PCK

Pack Integer into String

This string function returns the compacted form of a given integer using one byte of string for every two bytes of the integer.

PCK (numeric-value, length [,ERR=line-ref|,ERC=error-code])
numeric-value is any number in the range of 999999999999 to
B99999999999 (maximum of 12 digits, including sign); non-integer portion is ignored.
length
is any number in the range of 1 to 6 specifying the number of characters in the resultant string. The value of length must be at least the number of digits in numeric-value, including any minus or plus sign, divided by 2, rounded.
line-ref
is the program line number or label to branch to if an error is produced by this function.
error-code
is a programmer-defined error code. Valid values are positive or negative whole numbers.

If length is too small, an ERR=41 results.

This function is the reverse of the UPK function.

LET X$ = PCK(X,4)

If X = 12345678.901 the numeric value 12345678 is packed into a 4 character string resulting in the value $0D23394F$.

UPK function

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF