User Tools

Site Tools

Navigation:  Language Reference > 2 - Program Source Code Format > Compiler Directives >====== SIZE (memory size in bytes) ====== Previous pageReturn to chapter overviewNext page


SIZE( constant )


SIZE Supplies the amount of memory used for storage.
variable The label of a previously declared variable.
constant A numeric or string constant.
picture A picture token.

SIZE directs the compiler to supply the amount of memory (in bytes) used to store the variable, constant, or picture.

SIZE can also be used at run time. The compiler is smart in handling SIZE. If the size of the data is known at compile time, the compiler will use it. Otherwise, the compiler generates code to evaluate SIZE at run time.

For example, at run time:

·The size of a STRING, CSTRING, PSTRING and GROUP (including RECORD) pointed to by a given reference variable is retrieved from that variable.

·The size of a BLOB is retrieved by the call to appropriate RTL functions.

·The size of an array with variable dimensions is calculated on the basis of the size of one entry and number of actual elements of that array.


SavRec  STRING(1),DIM(SIZE(Cus:Record)             !Dimension the string to size of record

StringVar STRING(SIZE('SoftVelocity Corporation')) !A string long enough for the constant

LOOP I# = 1 TO SIZE(ParseString)                   !Loop for number of bytes in the string

PicLen = SIZE(@P(###)###-####P)                    !Save size of the picture

tmp   LONG

str1   STRING(15)

str2   CSTRING(16)

str3   &STRING

str4   &CSTRING


str3 &= NEW(STRING(17))

str4 &= NEW(CSTRING(18))

tmp = SIZE(str1)   ! returns 15

tmp = SIZE(str2)   ! returns 16

tmp = SIZE(str3)   ! returns 17

tmp = SIZE(str4)   ! returns 18

See Also:



FILE Structure Properties

size_memory_size_in_bytes_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)