SIZE

The SIZE function returns a vector that contains size and type information for its argument if no keywords are set. If a keyword is set, SIZE returns the specified quantity.

The returned vector is always of longword type. The first element is equal to the number of dimensions of Expression . This value is zero if Expression is scalar or undefined. The next elements contain the size of each dimension, one element per dimension (none if Expression is scalar or undefined). After the dimension sizes, the last two elements contain the type code (zero if undefined) and the number of elements in Expression , respectively. The type code is described in the table below.

  • IDL Type Codes

Type Code

Data Type

0

Undefined

1

Byte

2

Integer

3

Longword integer

4

Floating point

5

Double-precision floating

6

Complex floating

7

String

8

Structure

9

Double-precision complex

10

Pointer

11

Object reference

Calling Sequence

Result = SIZE( Expression )

Arguments

Expression

The expression for which size information is requested.

Keywords

The following keywords determine the return value of the SIZE function. The keywords are mutually exclusive -- specify at most one of the following.

DIMENSIONS

Set this keyword to return the dimensions of Expression . If Expression is scalar, the result is a longword scalar containing a 1. For arrays, the result is a longword array containing the array dimensions.

FILE_LUN

Set this keyword to return the file unit to which Expression is associated, if it is an IDL file variable, as created with the ASSOC function. If Expression is not a file variable, 0 is returned (0 is not a valid file unit for ASSOC).

N_DIMENSIONS

Set this keyword to return the number of dimension in Expression , if it is an array. If Expression is scalar, 0 is returned.

N_ELEMENTS

Set this keyword to returns the number of data elements in Expression . Setting this keyword is equivalent to using the N_ELEMENTS function.

STRUCTURE

Set this keyword to return all available information about Expression as an IDL_SIZE structure. Note that since the structure is a named structure, the size of its fields is fixed. The following are descriptions of the fields in the returned structure:

TYPE_NAME

Name of IDL type of Expression. ·

TYPEIDL

Type code of Expression. ·

FILE_LUN

If Expression is an IDL file variable, as created with the ASSOC function, the file unit to which it is associated. Otherwise, 0.

N_ELEMENTS

Number of data elements in Expression .

N_DIMENSIONS

If Expression is an array, the number of dimensions. Otherwise, 0.

DIMENSIONS

An 8-element array containing the dimensions of Expression .

TNAME

Set this keyword to return the IDL type of Expression as a string.

TYPE

Set this keyword to returns the IDL type code for Expression . See IDL Type Codes for details.

Example

Print the size information for a 10 by 20 floating-point array by entering:

PRINT, SIZE(FINDGEN(10, 20))

IDL prints:

   2   10   20   4   200

IDL shows that the array has 2 dimensions, equal to 10 and 20, a type code of 4, and 200 elements total.

Similarly, to print only the number of dimensions of the same array:

PRINT, SIZE(FINDGEN(10, 20), /N_DIMENSIONS)

IDL prints:

   2