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

Home » Public Forums » archive » forcing variable definition in IDL?
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: forcing variable definition in IDL? [message #24974 is a reply to message #24876] Tue, 01 May 2001 05:32 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Gernot Hassenpflug (gernot-nospam@kurasc.kyoto-u.ac.jp) writes:

> So, my question: is it possible in IDL 5.4 to force definition of
> variables, or at least to automate a variable-check in IDL.

It is certainly possible to "force" a variable to
have a certain definition. That's not the problem.
The problem is making it *stay* a certain definition.
That, in general, is not possible in IDL, since IDL
has dynamic typing capability.
>
> Alternatively, maybe I need to write a function that automatically
> checks the first use of a variable in a program. I have used the
> routine_info and routine_names functions to obtain information
> about variables in scope at the time.

You can check. But like recalcitrant children, they
will be doing something else the minute you turn
your back. :-)

> Does anyone know of either how to get IDL to check variables'
> definition,
> or how to write a function to do that?

IDL> theType = Size(variable, /Type)

Or, if you prefer the type "name":

IDL> theTypeName = Size(variable, /TName)

> I have also toyed with the idea of using each variable as a single-
> element array (eg. b(0) = 1), but that is most inelegant and lengthy.

Don't bother. IDL scalars *are* single element arrays:

IDL> a=5
IDL> a[0] = 6 & Print, a

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Dereferencing a Pointer Array
Next Topic: Array Concatenation Tutorial

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

Current Time: Wed Oct 08 17:29:38 PDT 2025

Total time taken to generate the page: 0.00406 seconds