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

Home » Public Forums » archive » name a variable with number
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: name a variable with number [message #87459 is a reply to message #87456] Tue, 04 February 2014 09:28 Go to previous messageGo to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On Tuesday, February 4, 2014 2:09:16 PM UTC, Fabien wrote:
> Hi,
>
>
>
>
>
> On 04.02.2014 14:57, David Fanning wrote:
>
>> I think in the hands of someone who knows what they are doing this can
>
>> be a powerful programming technique. I rarely see it used in those kind
>
>> of hands.:-)
>
>
>
> what David means is that most experienced programmers probably never
>
> even *needed* to create a variable dynamically.
>
>
>
> If the technique is available, this does not mean this technique is
>
> suitable for your problem. If you think you need X variables named
>
> var_0, var_1, ---, var_X than the algorithm you are thinking of is
>
> probably not the best one.
>
>
>
> In this case, a list (for IDL8+) or a pointer array (all versions) is
>
> probably a better solution.
>
>
>
> For example:
>
>
>
> var = PTRARR(25)
>
> for j=0, 24 do var[j]=PTR_NEW(whatever_you_want_to_put_inside)
>
>
>
> Fab


If anyone feels the inclination to cover this in more detail it'd be appreciated as I find myself using it quite often, normally as a shortcut to repeating the same thing over and over.

For example, say I have many different models datasets where I want to interact on the data on each individual model but I also want all the datasets to be available. I typically name the data modelA_variableA, modelB_variableA, etc and then loop over by setting thisModel_variableA=modelA_variableA using the type of execute command I posted above with "modelA" and "variableA" as the strings.

Is there a better (generic) way of doing this?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: accessing IDL internal (aka "built-in") routines
Next Topic: Error using data structures while reading ASCII file with different data types

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

Current Time: Wed Oct 08 17:54:06 PDT 2025

Total time taken to generate the page: 0.00264 seconds