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

Home » Public Forums » archive » Re: subverting IDL builtin variables !FORMYOWNPURPOSES
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: subverting IDL builtin variables !FORMYOWNPURPOSES [message #75256] Fri, 18 February 2011 19:34 Go to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 2/18/11 5:41 PM, Ed Hyer wrote:
> This is a terrible idea, but I'll feel better about doing it one of
> the Hard Ways once I've committed this awful cheat to posterity.
>
> The package has ~100 subroutines, and each subroutine has various
> types of output. All of this output ends up in logs, but now that the
> whole creature is built, it's time to set different levels of
> verbosity. My simple scheme is like this:
> DEBUG=0; put nothing in the log except fatal errors;
> DEBUG=1; include warnings and limited diagnostics;
> DEBUG=2; include full diagnostics, performance-related
> information, the kitchen sink.
>
> Now, I can think of three ways to do this:
> 1) Pass a VERBOSITY keyword from the top level through all of the
> subroutines. I'm not going to change 100 headers to add this (though I
> am going to change ~200 PRINT statements to IF(VERBOSITY gt XX) THEN
> PRINT).
> 2) Create a common block for the VERBOSITY level. I've never done
> this, but it seems like the right solution for this problem.
> 3) Put the VERBOSITY into a !VARIABLE that isn't being used for
> anything else. There are plenty to choose from, especially since this
> package doesn't actually generate any graphics, etc.
>
> Solution #3 is so easy... so wrong... so easy. Oh well.
> Have a great weekend, everybody.

I ended up using common blocks for my logging framework, but system
variables would work just as well.

See MG_LOG and MGffLogger in the dist_tools for the way I did it:

http://docs.idldev.com/dist_tools/

By the way, you don't have to subvert a pre-existing system variable,
you can create your own with DEFSYSV.

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
Re: subverting IDL builtin variables !FORMYOWNPURPOSES [message #75257 is a reply to message #75256] Fri, 18 February 2011 17:58 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
defsysv?

-Jeremy.
Re: subverting IDL builtin variables !FORMYOWNPURPOSES [message #75292 is a reply to message #75256] Wed, 23 February 2011 04:42 Go to previous message
SonicKenking is currently offline  SonicKenking
Messages: 51
Registered: October 2010
Member
> I ended up using common blocks for my logging framework, but system
> variables would work just as well.
>
> See MG_LOG and MGffLogger in the dist_tools for the way I did it:
>
>   http://docs.idldev.com/dist_tools/
>
> By the way, you don't have to subvert a pre-existing system variable,
> you can create your own with DEFSYSV.
>
> Mike
> --www.michaelgalloy.com
> Research Mathematician
> Tech-X Corporation

Hi Mike,

The MG_LOG is a really nice tool and inspiring. I did some
modifications to it and think it could be useful to others.

One limitation I felt for MG_LOG is that it accepts only a single
string message to print. I'd like to have something similar to the IDL
built-in PRINT, which accepts any number of arguments and also does
the logging as MG_LOG.

This is one tricky thing I always struggled, i.e. you cannot get the
full power of using variable length parameters without using
"Execute". But Execute is something I try to avoid as much as
possible, since it does not run on an IDL VM. Mike suggested before
that this can be solved by using DLM or embeded C programs. But I have
no idea how to do it. I would appreciate if anyone can come up with a
universal wrapper for this and is willing to share with us. :)

Anyway, I ended up re-using PRINTF for the logging and sneak the
modified logging program in the position of LUN. So it is something
like:

PRINTF, myLun(), a, b, c, etc

Where myLun() is a similar routine to MG_LOG.

They are similar in that they are both a wrapper that manages an
underlying logging object. They both control whether the message/
variables are actually printed out based on a logging level (1-5).

The differences are:
1. myLun() returns a lun for either the terminal (-1 or -2), or a
file, or /dev/null for suppressing the message to be printed.
2. myLun() accepts a level parameter indicating the level of this
message, e.g. myLun(5) for debugging level.
3. myLun() accepts a filename for logging in a file and once the file
is set, it is persistent until the logging is explicitly redirected to
another file/terminal.
4. The underlying objects can manage multiple output files. An new
file will be opened if a new filename is passed to myLun().

Some of the limitations are:
1. It cannot keep the output to both terminal and files at the same
without using "Journal", which is another thing I try to avoid.
2. Currently it only controls text printing. But I'd like to have
similar mechanisms but work for plottings.

I'll post the code if anyone is interested.

Yang
Re: subverting IDL builtin variables !FORMYOWNPURPOSES [message #75295 is a reply to message #75256] Tue, 22 February 2011 16:41 Go to previous message
MarioIncandenza is currently offline  MarioIncandenza
Messages: 231
Registered: February 2005
Senior Member
DEFSYSV was new to me: it's what I ended up using for this job. But
the dist_tools look really promising, and I'll have to look harder at
them.

Very happy with this solution. Many thanks Mike and Jeremy!

--Edward H.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Pixelwise temporal trend, problem with REFORM
Next Topic: Problems with reading images

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

Current Time: Wed Oct 08 13:37:53 PDT 2025

Total time taken to generate the page: 0.00680 seconds