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

Home » Public Forums » archive » temporary() problem
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: temporary() problem [message #86026 is a reply to message #86025] Tue, 24 September 2013 14:29 Go to previous messageGo to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 09/24/13 16:32, David Fanning wrote:
> spluque@gmail.com writes:
>
>> I'm not sure I understand why the variable 'a' below gets undefined after calling a procedure using temporary():
>>
>> IDL> a='a, b, c'
>> IDL> help, a
>> A STRING = 'a, b, c'
>> IDL> .run "test.pro"
>> % Compiled module: TEST.
>> IDL> test, a
>> IDL> help, a
>> A UNDEFINED = <Undefined>
>>
>>
>> The contents of test.pro:
>>
>> PRO TEST, str
>> ostr=strsplit(temporary(str), ', ', /extract)
>> END
>>
>>
>> Why is temporary() messing with the top level environment?
>
> Because variables are passed by reference in IDL, not by value (copied
> into the procedure). In this case, you are working with the variable str
> itself, not a copy of the variable.

I would go with the explanation that temporary() is "messing" with the
top level environment because that's what the programmer wrote it to do.

"Why is the computer doing what I told it to do, not what I want it to do?"

:o)


For the OP, try this for some obfuscatory fun:

IDL> a=['qwerty','a,b,c']
IDL> help, a
A STRING = Array[2]
IDL> print, a
qwerty a,b,c
IDL> .run "test.pro"
% Compiled module: TEST.
IDL> test, a[1]
IDL> print, a
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reading part of a netcdf file?
Next Topic: A newbie question regarding 3D plotting

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

Current Time: Sat Oct 11 01:34:37 PDT 2025

Total time taken to generate the page: 1.20129 seconds