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

Home » Public Forums » archive » Bug? Hash and System Variable
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Bug? Hash and System Variable [message #84351] Thu, 30 May 2013 21:08 Go to next message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
The following simple code errors out

defsysv, '!SOME_SYS_VAR', hash()
help, !SOME_SYS_VAR
(!SOME_SYS_VAR)['A'] = 1
end

The output is as follows
<Expression> HASH <ID=1 NELEMENTS=0>
% Expression must be an array in this context: !SOME_SYS_VAR.

The funny thing is that I can actually run the same command by typing it on the IDL prompt. So following command runs:

IDL> (!SOME_SYS_VAR)['A'] = 1
IDL> print, !SOME_SYS_VAR
A: 1

Is it a bug or feature? And how can I correct the code so it can run inside a routine instead of on the prompt (@ is the same as typing on the prompt).

Thanks!
Re: Bug? Hash and System Variable [message #84424 is a reply to message #84351] Sun, 02 June 2013 18:31 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
Thanks for the responses. So it is most likely a Bug.

I did find a workaround in case anyone is interested. A hash variable is essentially a pointer. Also the bug seems only affect system variable. So following workaround works.

defsysv, '!SOME_SYS_VAR', hash()
a_normal_var = !SOME_SYS_VAR
a_normal_var['A'] = 1
print, !SOME_SYS_VAR
end
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDLgrView question
Next Topic: Re: LinkedHash in IDL

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

Current Time: Wed Oct 08 15:18:02 PDT 2025

Total time taken to generate the page: 0.00451 seconds