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

Home » Public Forums » archive » Re: A smarter way to do this...
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: A smarter way to do this... [message #49592] Mon, 07 August 2006 15:41
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Mon, 07 Aug 2006 15:32:09 -0700, ChiChiRuiz@gmail.com wrote:

> Hi all,
>
> I'm looking for a smarter way to solve the following problem... any
> help is appreciated..
>
> I have an array of structures with a specified size as follows : info =
> replicate({name, label:'', vector:floarr(1000)}, size)
>
> Each structure has 2 fields, the parameter and a vector: info[i] =
> {name, 'ParameterName', ParameterVector}. (Note: i cannot change this
> format)
>
> for example, info[0] = {name, 'paramA', vectorA}
> info[1] = {name, 'paramB', vectorB}
> ...
>
> My goal is make a vector with its own parameter name:
> paramA = vectorA
> paramB = vectorB
>
> but it can be tedious when the "size" is large...don't really want to
> list them for 100 times. Is there a smarter/easier way to loop this?
> or I'll have to list it by hand how ever many "size" times?

You should probably use pointers in a case like this, but you can do what
you suggest with:

for i=0,size-1 do (scope_varfetch(info[i].label))=info[i].vector

Now that you've saved yourself the tedium, what will you do with those 100
different variables? You'll probably want to loop over them again, in
which case they were better off left tucked in that structure.

JD
[Message index]
 
Read Message
Previous Topic: A smarter way to do this...
Next Topic: convert to pixel to RA and DEC in degrees?

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

Current Time: Wed Oct 08 13:05:01 PDT 2025

Total time taken to generate the page: 0.03481 seconds