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

Home » Public Forums » archive » VARA1, VARB2, VARC8,...
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: VARA1, VARB2, VARC8,... [message #24253 is a reply to message #24190] Mon, 19 March 2001 14:02 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
I have had this same question when I went to IDL from Igor Pro, where
descriptive variable names are imperative not only for the readability
of the code, but even more so for its functionality :-(

I was told by one of the RSI folks that this approach is flawed, if you
think about it. Instead, you want to use a structure that is stored in a
generic variable, and place a descriptive name in one of the structure's fields:


temp = {name: '', data: ptr_new(/allocate)}
all_variables = replicate(temp, num_variables)
all_variables[0].name = 'var'+x
*(all_variables[0].data) = ....

instead of

If ('x' eq 'a1') then vara1=..... etc

If ('x' eq 'b2') then varb2=.... etc

which, BTW, will never work, because the string 'x' will never be equal
to the string 'a1' anyway.

This way, you don't have to *find* how to access variables you
dynamically name, when you need to work with them later. All you do then
is search the structure.
Cheers,
Pavel

Disclaimer : The above advice may have nothing to do with what the
question was about :-)
[Message index]
 
Read Message
Read Message
Previous Topic: Whats up in opening files: Unix vs. Windows
Next Topic: Filter

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

Current Time: Fri Oct 10 14:45:27 PDT 2025

Total time taken to generate the page: 1.27949 seconds