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

Home » Public Forums » archive » Re: Defining Integer Field in a Structure
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: Defining Integer Field in a Structure [message #27726 is a reply to message #27695] Thu, 01 November 2001 15:36 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
JD Smith <jdsmith@astro.cornell.edu> writes:


> Brian Bell wrote:
>>
>> Is there a way to define a field within a structure whose type is
>> integer? In my case, I want the field to be any integer from 0 to 4.
>> I know you can assign an actual integer to the field, but I don't want
>> to do this because I want the field value to change within certain
>> procedures and to return that value to the procedures calling it. I
>> would appreciate any help you might be able to offer.
>>
>
> This is illegal:
>
> IDL> a={0:"this", 1:"is",2:"a",3:"funny",4:"test"}
>
> so the short answer is no. However, if you just want 4 numbered
> "slots", try an array:
>
> IDL> a={vals:['this','is','a','funny','test']}
> IDL> print,a.vals[1]
> is
>
> if you'd like the types of each slot to be different, try at a pointer
> array. If you'd like the number of "slots" to be variable, try a
> pointer to a pointer array.

Following up on this diversion, it was in fact possible in IDL 5.2 and
earlier to make structures whose tag names were not valid IDL variable
names. For example, this statement was perfectly valid and executable:

x = create_struct('1',"this",'2',"is",'3',"funny",'4',"test ")

and it made exactly the structure you were expecting. However, I'm
not sure it would be useful, and more importantly these types of
antics are now forbidden by the IDL runtime.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: FSFC/IDL5.5 installation
Next Topic: RSI, Mac and Tru64

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

Current Time: Sat Oct 11 07:11:16 PDT 2025

Total time taken to generate the page: 0.80148 seconds