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

Home » Public Forums » archive » Re: Incremental variable names?
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: Incremental variable names? [message #37903 is a reply to message #37891] Mon, 02 February 2004 08:52 Go to previous messageGo to previous message
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
Jonathan, I apologize if this solution is way too obvious and you may
have something else in mind. Have you considered an array?

t = fltarr(10)
t(0)
t(1)
t(2)
If the values all need to be of different types, then pointers come to
the rescue.
t = ptrarr(10)
t(0) = ptr_new(0.5)
t(1) = ptr_new('hello')
t(2) = ptr_new(dblarr(100,400)
print, *t(0)
print, *t(1)
and so forth

Plus you can extend the length at will
t = [t, ptr_new('extension works')]
or remove elements, retaining only some.
t = t([1, 3, 4])

Is there a reason why this wouldn't work for you?

M. Katz.

Jonathan Greenberg <greenberg@ucdavis.edu> wrote in message news:<BC430FE2.18E9C%greenberg@ucdavis.edu>...
> Have a question about variable names. Is there any way to create and then
> call variable names that have some incremental value in them, e.g.:
>
> t0
> t1
> t2
>
> Etc... I want to be able to first create and assign a value to tn where n =
> 0 to whatever, and then be able to subsequently call that variable using a
> loop.
>
> --j
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: object graphics question
Next Topic: Re: Virtual Machine Crashes :-(

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

Current Time: Fri Oct 10 03:59:31 PDT 2025

Total time taken to generate the page: 0.66650 seconds