comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » bug? or how to distinguish between a Hash and an array of Hashes ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
bug? or how to distinguish between a Hash and an array of Hashes ? [message #83397] Mon, 04 March 2013 06:16
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
hi,

Is there any way to distinguish between a hash object and an array of
hash objects? Normally I use the SIZE() function to test for data
type, etc. However, in this case, SIZE() doesn't appear to be able to
distinguish between a single, scalar HASH, and an array of HASHes.

Consider the following test code:

pro test

a = hash('first', 1, 'second', 2)
b = hash('third', 3, 'fourth', 4, 'fifth', 5)
print, 'Output of SIZE() for a HASH varible: ', size(a)
c = [a,b]
print, 'Output of SIZE() for an array of HASH variables: ',
size(c)

end

this gives the following output:

Output of SIZE() for a HASH varible: 1
2 11 2
Output of SIZE() for an array of HASH variables:
1 2 11 2

so.. identical. It appears that when you pass a scalar HASH object to
SIZE(), it returns the number of elements in the HASH, and the
N_Dimensions fields shows it as being a 1D array, rather than a
scalar.

Is there another way to distinguish between the two cases? This
problem would apply to LIST objects as well.

thanks!
Mark
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Split an int array into different arrays
Next Topic: Re: bug? or how to distinguish between a Hash and an array of Hashes ?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:36:45 PDT 2025

Total time taken to generate the page: 0.00568 seconds