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

Home » Public Forums » archive » Re: Global variables and command line
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: Global variables and command line [message #11568 is a reply to message #11566] Fri, 17 April 1998 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Daniel SAGE wrote:
>
> Hello,
>
> I would like use the variables created in the input command line inside
> the procedures/functions. But in my application where I automatically
> generate IDL code, I can't use the common mechanism or passing by
> parameters.
>
> pro run
> resolve_routine, "test"
> call_procedure, "test"
> end
>
> pro test
> common var
> print, v1
> print, v2
> end
>
> IDL> common var, v1
> IDL> v1=111
> IDL> v2=222
> % Compiled module: RUN.
> % Compiled module: TEST.
> IDL> run
> % Procedure was compiled while active: RUN. Returning.
> % Compiled module: TEST.
> 111
> % PRINT: Variable is undefined: V2.
> % Execution halted at: TEST 10 HD:Desktop Folder:test.pro
>
> % $MAIN$
>
> How is it possible to make V2 visible inside the test procedure when I
> can't pass the parameters with the run procedure ?
>
> Thanks
>
Your problem is that you define your common block only with v1 - and
once it is defined, you can't change it!!

The above example will work if you type common var,v1,v2 on the command
line. However, a better approach would probably be to call EXECUTE (or
CALL_PROCEDURE, CALL_FUNCTION) to "execute" your procedure or function
that you generate automatically. There should always be some way of
parameter passing. Even if you don't know how many variables you will
need in advance neither their name, you could still construct a
structure and pass that into the function/procedure. I have a CHKSTRU
function in my library (html below) which you can use to see if a
certain structure tag is defined.

Hope this helps,
Martin

--
------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: temporary function
Next Topic: Re: Ranting and Raving and getting back to global variables

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

Current Time: Sat Oct 11 12:30:24 PDT 2025

Total time taken to generate the page: 0.53578 seconds