Re: Passing a structured variable as an argument of procedure [message #14703] |
Mon, 22 March 1999 00:00  |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
VU KHAC Tri wrote:
>
> Hi folks,
>
> I'm very new in IDL programming.
> My question is can I pass a structured variable as an argument of a
> procedure ?
> How to define this ?
(A) if you create a structure outside of your procedure, you can pass it
like any other variable either as parameter or keyword:
a = { test:'my name', value=100 }
my_proc,a
or my_proc,structure=a
(you may find my little chkstru function helpful to test whether
what you passed really is a structure and [optionally] if it contains
the fields ("tags") that you need. You can get it from my webpage (see
below)).
(B) same thing holds if you create your structure within your procedure.
Example:
pro my_proc,newstru
newstru = { dummy:1.0, truevalue:1 }
end
(and in "main"):
my_proc,test
print,test
Hope this helps,
Martin.
--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Engineering&Applied Sciences, Harvard University
109 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA
phone: (617)-496-8318
fax : (617)-495-4551
e-mail: mgs@io.harvard.edu
Internet-homepage: http://www-as.harvard.edu/people/staff/mgs/
------------------------------------------------------------ -------
|
|
|