PAK
WTSupported in traditional Synergy on Windows
|
|
USupported on UNIX
|
VSupported on OpenVMS
|
The PAK routine is deprecated; we recommend you use the p data type instead. See Packed and implied-packed for information on the p data type. |
xcall PAK(record, size, field[, ...])
Arguments
record
The record that contains the fields to be compressed. (a)
size
A variable that contains the size of the compressed record after the PAK operation. (n)
field
One or more decimal fields in the specified record. These fields must exist in record and must be listed in ascending order as they appear in the record. (d)
Discussion
The PAK subroutine compresses fields of numeric data to save disk space. Each packed field produced by PAK has the following length:
(number of characters/2) + 1
Use the UNPAK subroutine to restore the fields’ original values.
If we have the following data division:
record rec1 fld1 ,d5 fld2 ,a4 fld3 ,d18 fld4 ,d9 fld5 ,a33 fld6 ,d3 record ,x fld1x ,a3 fld2x ,a4 fld3x ,a10 fld4x ,a5 fld5x ,a33 fld6x ,a2 record size ,d2
the following statement compresses rec1 down to the fields described in the overlay record:
xcall pak(rec1, size, fld1, fld3, fld4, fld6)
This shortened record can then be output to a file to save space. When you’re ready to read the record back, the following statement restores the original values to the fields.
xcall unpak(rec1, fld1, fld3, fld4, fld6)
Assuming the above layout is in the file layout.def, the following subroutine save the data from one file to a packed backup file.
subroutine bck_restore a_flag ,d a_source ,a a_bckup ,a .include "layout.def" .define BCKUP ,1 .define RESTORE ,2 .define SRCCHN ,10 .define BCKCHN ,11 proc if (a_flag.eq.BCKUP) then begin open(BCKCHN, o, a_bckup) open(SRCCHN, i, a_source) repeat begin reads(SRCCHN, rec1) [eq = done] xcall pak(rec1, size, fld1, fld3, fld4, fld6) puts(BCKCHN, rec1) end end else begin open(BCKCHN, i, a_bckup) open(SRCCHN, o, a_source) repeat begin gets(BCKCHN, rec1) [eq = done] xcall unpak(rec1, fld1, fld3, fld4, fld6) writes(SRCCHN, rec1) end end done, close SRCCHN close BCKCHN xreturn endsubroutine