Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 3 Tools : GENPACK

GENPACK
Returns a syntax V string containing the same internal packed decimal value as the input syntax P value, right-justified. (F)
Invoking
string = GENPACK(value, length, decimal)
 
Usage
Each byte of the returned string is initialized to 0 and the input packed decimal representation is moved into the string right-justified.
Example
The following rule uses GENPACK to create a buffer containing packed values.

 
RULE EDITOR ===> SCROLL: P
A2(V,L);
_ LOCAL STR;
_ -------------------------------------------------------------------------------
_ ----------------------------------------------------------------+--------------
_ STR = GENPACK(V,L,0); | 1
_ CALL ENDMSG(STR || '; LENGTH OF STRING=' || LENGTH(STR)); | 2
_ -------------------------------------------------------------------------------

 
A2(-0.003,5) results in a 5‑byte STR buffer. The first 4 bytes are 0 (and display as blanks), and the fifth byte is x'3D' (a hexadecimal number that displays as “.”), which is the internal packed representation for -3.
A2(0,7) results in a 7‑byte STR buffer. The first 6 bytes are 0 (and display as blanks), and the seventh byte is x'0C' (a hexadecimal number that displays as “.”).

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved