SIZEOF Function
Returns the data size in bytes of the given expression.
Usage
result = SIZEOF(expr)
Input Parameters
expr—Any valid PV-WAVE expression. Usually a variable for which the data size in bytes is desired.
note | This function handles all PV-WAVE data types except those of type UPVAR (type = 9). |
Returned Value
result—A LONG containing the size of the data area occupied by the supplied argument.
Keywords
None.
Discussion
In order to properly count the number of bytes in variables consisting of nested data types, SIZEOF calls itself recursively. In doing so, the arguments in the recursive calls are almost always expressions rather than simple variables. Because PV-WAVE passes expressions by value instead of by reference, a copy of the evaluated expression is made internally each time. Usually this poses no problem. However, if the original argument consists of nested structures that are large in data size compared to the available virtual memory on the computer, then this routine could possibly fail.
Example
; Define a simple structure:
s1 = { my_struct1, x:FLTARR(3,4), y:STRARR(10), z:INTARR(5,6) }
; Define another structure, more complex and embedding the other:
s2 = { my_struct2, a:DBLARR(2,8), b:ASARR(), c:LIST(), $
d:REPLICATE( {my_struct1}, 100) }
; Fill the structure with data:
s2.d.y = REPLICATE('Dave', 10)
s2.c = LIST( INTARR(2,4), DCOMPLEXARR(12) )
s2.b = ASARR( 'one', BYTARR(15), 'two', DINDGEN(25) )
; Define s3 to be an ARRAY of s2 structures:
s3 = REPLICATE( s2, 200 )
PRINT, 'Size of s3 in bytes = ', SIZEOF( s3 )
See Also
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.