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

Home » Public Forums » archive » How to create a varying variable?
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: How to create a varying variable? [message #89394 is a reply to message #89388] Mon, 06 October 2014 08:26 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 10/06/14 10:13, Madhavan Bomidi wrote:
> Hello,
>
> I want to create a varying variable, 'varJJJ' as below:
>
> varJJJ = FLTARR(nc,nr)
>
> Here JJJ = STRING(indgen(101),FORMAT='(I03)')
>
> Is this possible? Can anyone have a better suggestion?
>
> Thanks in advance,
> Madhavan

First thing that occurs to me is: why?

I'm not trying to be obstreperous, just asking for some context since
this sort of request is usually more of a design issue than a language one.

cheers,

paulv


p.s. And, FWIW, Matthew's suggestion using a hash is what I would
recommend since you can use the dynamic "JJJ" to access the particular
value that you want. E.g.

IDL> h=hash()

Use string of number:

IDL> jjj='101'
IDL> h[jjj] = findgen(20,10)
IDL> help, h['101']
<Expression> FLOAT = Array[20, 10]

Or use actual number (why convert to string?):

IDL> nnn=101
IDL> h[nnn] = dindgen(14)
IDL> help, h[101]
<Expression> DOUBLE = Array[14]

where, as you can see, h['101'] and h[101] reference different values in
the hash.

If you have an older version of IDL (i.e. no hashes) then you could put
together something similar using pointer arrays.

All of the plumbing (for either methodology) could then be wrapped up
into "Init", "Set" and "Get" functions so your code is protected from
the implementation details.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Problem with mpfit (possibly a string length issue)
Next Topic: How can i write Δ in Y axis

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

Current Time: Wed Oct 08 17:32:45 PDT 2025

Total time taken to generate the page: 0.00242 seconds