previous next top contents index framed top this page unframed
Figure 47–33. size (GENERIC)
| COMPILETIME INTEGER PROCEDURE size (INTEGER typeCode); $BUILTIN SPECIAL INTEGER PROCEDURE size (CLASS c); LONG INTEGER PROCEDURE size (POINTER p); |
size computes the number of storage units occupied by a data type, CLASS, or dynamic object. It returns an INTEGER; use $lSize (see Section 40.27) to obtain the size in question as a LONG INTEGER.
The INTEGER form returns the number of storage units required by the data type with type code typeCode (see Section 2.7). If the argument to the INTEGER form of size is $recordCode, size returns 0. If the argument is an extended type code for an explicitly sized type (see Appendix A), size returns the number of bytes the explicitly sized type occupies; for example, size($boolean1Code) is 1.
If the argument is not a valid type code, the effect of size is undefined.
The CLASS form returns the number of storage units required by the data fields in a record of the CLASS c. PROCEDURE fields play no part in the size. The CLASS form is always evaluated at compiletime.
In the POINTER form, p points to a dynamic object. The size of the object, in storage units, is returned. In the case of the data section, the size of the entire data section, not just the data interface fields, is returned. If p is Zero, 0L is returned; if p is not valid, an error message is issued.
These PROCEDUREs produce machine-dependent results, since the sizes of the data types and the interpretation of storage units vary across implementations.
$ioSize should be used instead of size to compute the sizes of data types written to data files.
A garbage collection cannot occur during a call to size.
Example 47–34. Use of size
i := size(integerCode); i is set to the the number of storage units required by an INTEGER. |
MAINSAIL Language Manual, Section 47.31