David,
Could someone explain the last definition? If I were to pass myzone by
reference to a procedure, it's the packed version that gets passed. How
should I pass this zone?
The definition of a field in an externally described file is its format in
that file. If the field is not also named in a data structure or
stand-alone D spec, then the compiler may use a different format for the
field. In general, both packed and zones fields will be stored internally
as packed. One reason it does this is, at least on the CISC boxes, I
believe performance of the arithmetic operations was better when both
operands were packed. But aside from performance, consider what happens
when the same field name exists in multiple files used by a program. As
long as the number of digits and decimal positions is the same in each file,
you can do that even when some files declare it as zoned and others as
packed. The reason that works is the field is moved from its external
definition to the program variable assigned to hold that value, and that
program variable is packed.
In order to force a program variable to be a particular format, name it on a
D spec and signify the type, or include the variable in a data structure.
An easy way to do the later is to use an externally described DS based on
the file you are using. This forces each of the fields in the program to
use the same format as the external definition. Note however that if
multiple files have the same field name, you can't have that name appear in
multiple data structures because the program variable must exist in only one
memory location.
Doug
As an Amazon Associate we earn from qualifying purchases.