Re: Suppressing diagnostic messages en masse [message #47309] |
Fri, 03 February 2006 10:11 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jean H. writes:
>
> What is wrong with that? Especially if you set it only when you are
> "done" developing?
Are you kidding!? It's when you *think* you are done
developing that you need this information the most!
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Suppressing diagnostic messages en masse [message #47310 is a reply to message #47309] |
Fri, 03 February 2006 09:43  |
Jean[1]
Messages: 8 Registered: November 2005
|
Junior Member |
|
|
>> Had you thought to use MESSAGE to achieve your "various
>> diagnostic ends", you would be golden. Just set !Quiet=1
>> and run the darn thing. No messages.
>
> Please forget it. I must have been out of my mind
> to put something like this on a newsgroup. !Quiet=1!?
> I am about to create another generation of programmers
> with no friggin' idea what is going on. :-(
>
> Cheers,
> David
What is wrong with that? Especially if you set it only when you are
"done" developing?
Jean
|
|
|
Re: Suppressing diagnostic messages en masse [message #47319 is a reply to message #47310] |
Thu, 02 February 2006 17:06  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
Ed Hyer wrote:
> Hey great minds,
>
> I am engaged in semi-permanent debugging of some pretty long scripts,
> which in the course of developing I have peppered with PRINT statements
> to achieve various diagnostic ends.
>
> I don't think the script is "final," whatever that means, but it's time
> to do some production runs, where the script will be invoked 10,000
> times, instead of the usual 1.
>
> I can do a search-and-replace to comment out the diagnostics for this
> purpose, but what would really be nice is if I could somehow put a
> keyword flag into the routine that, when set, would suppress|promote
> the diagnostic messages. Sounds like the sort of thing that might
> exist. Anyone know how to do this?
I don't know about "system" level keywords to do this, but I usually add a "Debug" keyword
to my procedures - particularly widget code, but other stuff too.
You should be able to do a supervised global search and replace so that
PRINT,
becomes
IF ( KEYWORD_SET(Debug) ) THEN PRINT,
However, if you have a lot of PRINTs, you might want to "block" them, e.g.
IF ( KEYWORD_SET(Debug) ) THEN BEGIN
PRINT, x
PRINT, y
PRINT, a,b,c
....
ENDIF
It depends on how you've written the code. Lots of "IF ( KEYWORD_SET(Debug) )..." lines
could slow things down a bit (and "a bit" multiplied by 10000 is a lot).
A sed or awk filter for the code might also be an option. That is, you run the code
through sed or awk to comment or uncomment the debug print statements depending on your need.
paulv
--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
|
|
|
Re: Suppressing diagnostic messages en masse [message #47320 is a reply to message #47319] |
Thu, 02 February 2006 17:03  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Had you thought to use MESSAGE to achieve your "various
> diagnostic ends", you would be golden. Just set !Quiet=1
> and run the darn thing. No messages.
Please forget it. I must have been out of my mind
to put something like this on a newsgroup. !Quiet=1!?
I am about to create another generation of programmers
with no friggin' idea what is going on. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Suppressing diagnostic messages en masse [message #47321 is a reply to message #47320] |
Thu, 02 February 2006 17:00  |
mmeron
Messages: 44 Registered: October 2003
|
Member |
|
|
In article <1138927542.301363.217360@z14g2000cwz.googlegroups.com>, "Ed Hyer" <ejhyer@gmail.com> writes:
> Hey great minds,
>
> I am engaged in semi-permanent debugging of some pretty long scripts,
> which in the course of developing I have peppered with PRINT statements
> to achieve various diagnostic ends.
>
> I don't think the script is "final," whatever that means, but it's time
> to do some production runs, where the script will be invoked 10,000
> times, instead of the usual 1.
>
> I can do a search-and-replace to comment out the diagnostics for this
> purpose, but what would really be nice is if I could somehow put a
> keyword flag into the routine that, when set, would suppress|promote
> the diagnostic messages. Sounds like the sort of thing that might
> exist. Anyone know how to do this?
>
Just use a keyword flag, as you said.
1) Add to the call line of the routine something like ",diagnose = diag'
2) Add to the body of the routine "diflag = keyword_set(diag)'
3) Run search and replace, replacing every instance of "print," with
"if diflag then print,"
The choice of variable names is, of course, up to you.
Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
|
|
|
Re: Suppressing diagnostic messages en masse [message #47322 is a reply to message #47321] |
Thu, 02 February 2006 16:57  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ed Hyer writes:
> I am engaged in semi-permanent debugging of some pretty long scripts,
> which in the course of developing I have peppered with PRINT statements
> to achieve various diagnostic ends.
>
> I don't think the script is "final," whatever that means, but it's time
> to do some production runs, where the script will be invoked 10,000
> times, instead of the usual 1.
>
> I can do a search-and-replace to comment out the diagnostics for this
> purpose, but what would really be nice is if I could somehow put a
> keyword flag into the routine that, when set, would suppress|promote
> the diagnostic messages. Sounds like the sort of thing that might
> exist. Anyone know how to do this?
Had you thought to use MESSAGE to achieve your "various
diagnostic ends", you would be golden. Just set !Quiet=1
and run the darn thing. No messages.
But PRINT is going to print, no matter what.
;******************************************************
PRO test
Print, 'This is PRINT message'
Message, 'This is a message from MESSAGE.', /Informational
end
*********************************************************
IDL> .COMPILE test
Compiled module: TEST.
IDL> test
This is PRINT message
TEST: This is a message from MESSAGE.
IDL> !Quiet=1
IDL> test
This is PRINT message
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|