The SIZE function can also be used to determine whether a variable holds a scalar value or an array. Setting the DIMENSIONS keyword causes the SIZE function to return a 0 if the variable is a scalar, or the dimensions if the variable is an array, as shown in the following example:
A = 1 B = [1] C = [1,2,3] D = [[1,2],[3,4]] PRINT, SIZE(A, /DIMENSIONS) PRINT, SIZE(B, /DIMENSIONS) PRINT, SIZE(C, /DIMENSIONS) PRINT, SIZE(D, /DIMENSIONS)
IDL Prints:
0 1 3 2 2