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

Home » Public Forums » archive » Re: help: Type & size checking
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: help: Type & size checking [message #14734 is a reply to message #14730] Thu, 25 March 1999 00:00 Go to previous message
Phil Aldis is currently offline  Phil Aldis
Messages: 11
Registered: February 1999
Junior Member
In article <7dd618$j5i@hermes.fundp.ac.be>,
"Tri VU KHAC" <tvk@info.fundp.ac.be> wrote:
> Hi folks,
> Given a structured variable, how can I verify its type and its size as
> in C/C++ (sizeof, typeof) ?
> Thanks in advance.
> Best regards.
> Tri.
>
>

I presume a structured variable means just a structure, in which case it's
quite simple. I'm not entirely sure what sizeof returns, but if you're trying
to find out the number of tags in the structure then the function is N_Tags

IDL> mystruct = {string:'', integer:0,float:0.}
IDL> print, N_Tags(mystruct)
3

If however you want to find tou the actual byte size of it then specify the
keyword LENGTH like this:

IDL> print, N_Tags(mystruct, /LENGTH)
16
Remember /LENGTH means LENGTH=1, which sets the keyword.

However bear in mind this excerpt from the IDL help files:

Note The length of a structure is machine dependent. The length of a given
structure will vary depending upon the host machine. IDL pads and aligns
structures in a manner consistent with the host machine's C compiler.

The way to find out the type of a variable is to use the Size function with
the type keyword set. The different variables are numbered like this (check
out the help file on Size)

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
12 Unsigned Integer
13 Unsigned Longword Integer
14 64-bit Integer
15 Unsigned 64-bit Integer

However, bear in mind that 12-15 are specific to IDL5.2.

IDL> print, Size(mystruct, /TYPE)
8
IDL> print, Size(mystruct.integer, /TYPE)
2

...........so you can find out that mystruct is a structure and and that the
integer tag is an integer.

Anyway I hope this all helps.

Cheers,
Phil


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Strange Bug with numeric double constants
Next Topic: Re: Type define

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

Current Time: Fri Oct 10 19:50:16 PDT 2025

Total time taken to generate the page: 1.35649 seconds