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

Home » Public Forums » archive » Re: Little CREATE_STRUCT issue
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
Re: Little CREATE_STRUCT issue [message #43226] Thu, 24 March 2005 09:11
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Thu, 24 Mar 2005 13:34:58 +0000, Ricardo Bugalho wrote:

> Hi,
> I want to use CREATE_STRUCT like this:
>
> myStruct = CREATE_STRUCT(['tag1', 'tag2'], [100, 200])
>
> Yes, I have a structure where all elements are of the same type.
> Is there any magic way to do it, or I'll just have to write a small
> function?

You can build it up "piece by piece" using CREATE_STRUCT's ability to
extend structures, like:

myStruct=create_struct('tag1',100)
myStruct=create_struct(myStruct,'tag2',200)
...

which could easily be made into a general function. This is inefficient
for large structures, since it copies and extends the structure once for
each tag, but at least it works.

I suspect RSI decided that if all your values are the same type, you could
just put them in an array and save yourself the trouble of making a
structure out of them... and maybe they have a point.

JD
Re: Little CREATE_STRUCT issue [message #43232 is a reply to message #43226] Thu, 24 March 2005 08:37 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> There is no magic in computer programming. (Except,
> of course, with objects.)

But there are magic numbers in programming. ;-)
http://www.catb.org/~esr/jargon/html/M/magic-number.html

-Mike

P.S. Sorry for the off-topicness.
Re: Little CREATE_STRUCT issue [message #43244 is a reply to message #43232] Thu, 24 March 2005 05:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ricardo Bugalho writes:

> I want to use CREATE_STRUCT like this:
>
> myStruct = CREATE_STRUCT(['tag1', 'tag2'], [100, 200])
>
> Yes, I have a structure where all elements are of the same type.
> Is there any magic way to do it, or I'll just have to write a small
> function?

There is no magic in computer programming. (Except,
of course, with objects.)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: GDL?
Next Topic: Another XML Question

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

Current Time: Sat Oct 11 08:32:47 PDT 2025

Total time taken to generate the page: 1.19920 seconds