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

Home » Public Forums » archive » Re: Scope_VarFetch Bug or Feature?
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
Re: Scope_VarFetch Bug or Feature? [message #47500] Tue, 14 February 2006 18:00 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
retsil@iinet.net.au writes:

> I think that Scope_VarFetch certainly opens up a lot of possibilities.
> At first I thought that it was just a hack tool for IDL, but it
> actually has some legitamite uses.

I can't really believe (or discuss) what I am doing with
it. But, yes, I am very, very impressed. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Scope_VarFetch Bug or Feature? [message #47501 is a reply to message #47500] Tue, 14 February 2006 17:52 Go to previous messageGo to next message
retsil is currently offline  retsil
Messages: 2
Registered: March 2004
Junior Member
I think that Scope_VarFetch certainly opens up a lot of possibilities.
At first I thought that it was just a hack tool for IDL, but it
actually has some legitamite uses.

For example, I use Scope_VarFetch to bring DICOM images and object
properties into the context of a procedure.
https://www.rsinc.com/codebank/search.asp?FID=397

Robbie
Re: Scope_VarFetch Bug or Feature? [message #47502 is a reply to message #47501] Tue, 14 February 2006 16:31 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Robbie Barnett" <retsil@zipworld.com.au> writes:
> Dear David,
>
> I think that the trick is to test for the number of elements returned
> from Scope_VarFetch before you assign it to a variable.

This is definitely how I did it in the past. Except I used
ROUTINE_NAMES(), and I used SIZE() instead of N_ELEMENTS().

But other than that, totally the same :-)
Craig
Re: Scope_VarFetch Bug or Feature? [message #47503 is a reply to message #47502] Tue, 14 February 2006 14:51 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield writes:

> David Fanning wrote:
>> P.S. Let's just say we were burning about $1000/hour with
>> a room full of Ph.D. physicists trying to figure it out from
>> the documentation earlier today, to no avail. :-(
>
> Must be a big room!

Well, it's government money. In this country it's easy to
raise more just by lowering taxes. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Scope_VarFetch Bug or Feature? [message #47504 is a reply to message #47503] Tue, 14 February 2006 14:46 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> P.S. Let's just say we were burning about $1000/hour with
> a room full of Ph.D. physicists trying to figure it out from
> the documentation earlier today, to no avail. :-(

Must be a big room!

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Scope_VarFetch Bug or Feature? [message #47505 is a reply to message #47504] Tue, 14 February 2006 14:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
=?ISO-8859-2?Q?F=D6LDY_Lajos?= writes:

> well, you can check it first:
>
> help, out=s, (Scope_VarFetch(names[j], Level=1, /Enter))
> if strpos(s, 'UNDEFINED =') gt 0 then print, 'Undefined'
>
> (you can't retrieve an undefined variable, but you can get a
> reference to it :-)
>
> And I think the ENTER keyword works, it just creates an undefined
> variable :-) You can create a defined variable by
>
> (Scope_VarFetch('something_new', Level=1, /Enter))=0

Ah, now all that screwy parentheses stuff I remember from
a couple of months ago when I first starting looking at
SCOPE_VARFETCH is starting to make some sense to me! :-)

Thanks guys.

Cheers,

David

P.S. Let's just say we were burning about $1000/hour with
a room full of Ph.D. physicists trying to figure it out from
the documentation earlier today, to no avail. :-(

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Scope_VarFetch Bug or Feature? [message #47506 is a reply to message #47505] Tue, 14 February 2006 14:23 Go to previous messageGo to next message
Foldy Lajos is currently offline  Foldy Lajos
Messages: 268
Registered: October 2001
Senior Member
Hi David,

well, you can check it first:

help, out=s, (Scope_VarFetch(names[j], Level=1, /Enter))
if strpos(s, 'UNDEFINED =') gt 0 then print, 'Undefined'

(you can't retrieve an undefined variable, but you can get a
reference to it :-)

And I think the ENTER keyword works, it just creates an undefined
variable :-) You can create a defined variable by

(Scope_VarFetch('something_new', Level=1, /Enter))=0


regards,
lajos


On Tue, 14 Feb 2006, David Fanning wrote:

> Folks,
>
> Here is a short test program and main-level program:
>
> ;*****************************************************
> PRO test
>
> names = Scope_Varname(Level=1,Count=varcount)
> FOR j=0,varcount-1 DO BEGIN
> Print, 'Fetching variable ' + names[j] + '...'
> mainvar = Scope_VarFetch(names[j], Level=1, /Enter)
> Help, mainvar
> ENDFOR
>
> END
>
> a = 5
> b = c
> test
>
> END
> ;*****************************************************
>
> Compile and run the main-level program. Yes, it will
> cause an error. Don't worry about it. :-)
>
> When the error occurs, you will have two variables at
> the main level (LEVEL=1 in SCOPE_ parlance), a and b.
> The variable a is equal to 5 and b is undefined.
>
> Now, just type "test" and the test program runs.
> It will find both variables at the main level.
> But, as far as I can tell there is no way to learn
> anything more about the variables unless I retrieve
> them. BUT, I can't retrieve an undefined variable.
> It causes an error. :-(
>
> (According to the documentation the ENTER keyword should
> cause a variable with the name I am trying to fetch (b, in
> this case) to be created at the main-level, but this
> doesn't seem to work either. At least I still get the error.
> This DOES seem like a bug to me.)
>
> This is all causing me some heartburn, because I need to
> retrieve variables at a particular level and save them.
> All works well unless I try to retrieve undefined variables,
> and in this particular application, I cannot assume there
> won't be undefined variables.
>
> Does this seem like a bug to you, or a feature? Is the
> only alternative to CATCH the error?
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
Re: Scope_VarFetch Bug or Feature? [message #47507 is a reply to message #47506] Tue, 14 February 2006 14:22 Go to previous messageGo to next message
Robert Barnett is currently offline  Robert Barnett
Messages: 70
Registered: May 2004
Member
Dear David,

I think that the trick is to test for the number of elements returned
from Scope_VarFetch before you assign it to a variable.

;*****************************************************
PRO test01

names = Scope_Varname(Level=1,Count=varcount)
FOR j=0,varcount-1 DO BEGIN
s = n_elements(Scope_VarFetch(names[j], Level=1, /Enter))
Print, 'Fetching variable ' + names[j] + ' with n_elements ' +
string(s)
if (s gt 0) then begin
mainvar = Scope_VarFetch(names[j], Level=1)
Help, mainvar
endif
ENDFOR

END
;*****************************************************

Cheers
Robbie
Re: Scope_VarFetch Bug or Feature? [message #47551 is a reply to message #47500] Thu, 16 February 2006 14:41 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Tue, 14 Feb 2006 19:00:21 -0700, David Fanning wrote:

> retsil@iinet.net.au writes:
>
>> I think that Scope_VarFetch certainly opens up a lot of possibilities.
>> At first I thought that it was just a hack tool for IDL, but it actually
>> has some legitamite uses.
>
> I can't really believe (or discuss) what I am doing with it. But, yes, I
> am very, very impressed. :-)

IDLWAVE uses the precursor to SCOPE_VARFETCH, the undocumented
ROUTINE_NAMES, to allow pulling and examining variables from other
calling stack levels while stopped deep in a calling sequence. I like
to think that that pushed RSI over the edge to bundle it into a
supported set of routines (that and I bugged one of the developers
about it mercilessly). It's very useful. In object/widget code, I
often have a "Send project to command line" choice, which lets people
play with the object directly.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: [OT] english and spanish; was: Leer archivos ASCII
Next Topic: XYOUTS Decimal format

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

Current Time: Wed Oct 08 14:53:40 PDT 2025

Total time taken to generate the page: 0.00651 seconds