Sometimes you cannot check for everything, though I, too, check for zero before doing divides. Recently I had to put a series of MONITOR's in our invoice print program wrapped around EVAL's. Some data elements, due to bad user input, were causing "Field too small to hold the result". When I monitored, I also wrote an error log record and then printed the log (but only if there were errors). So, if the potential error is critical, one needs to do more than just MONITOR; some, such around an OPEN, are just anal reflexes (but I still do 'em many times).
Jerry C. Adams
IBM System i Programmer/Analyst
--
B&W Wholesale
office: 615-995-7024
email: jerry@xxxxxxxxxxxxxxx
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rory Hewitt
Sent: Monday, February 22, 2010 7:32 PM
To: RPG programming on the IBM i / System i
Subject: Re: Quieter Monitors
No, it's not a formal name :)
I guess I prefer to write code which up-front checks (and caters) for as
many errors as I can think of. Of course this means that the code is full of
little IF-clauses checking for this error and that. So I'd be in your latter
group.
I've never liked the MONITOR op-code, because it allows developers to rely
on the system to catch things which they should have checked for in the
first place. In Scott Klement's article which Kurt linekd to, Scott uses his
CleanUp() procedure to clean up job log errors that might happen if he
attempts to divide by zero. Me, I would have checked for zero before the
divide. Likewise with the other errors.
I *am* anal about job log messages <grin>
Of course, there's no reason why you couldn't write a procedure similar to
Scott's CleanUp() procedure, which cleans up every job log message:
monitor;
//stuff goes here
on-error;
CleanUpJobLog();
// error processing goes here
endmon;
but you'd probably want to use the QMHLJOBL or QGYOLJBL API rather than
QMHRCVPM, since you might want to remove low-level messages which were sent
to IBM sub-programs too.
On Mon, Feb 22, 2010 at 4:32 PM, Jose Antonio Salazar Montenegro <
0jsalazarm@xxxxxxxxxxxxx> wrote:
Why yes, they are. That's why I'm changing them.
I'm sure it's not the formal name, what I meant was doing what could
trigger an error and monitor for it rather than programmatically prevent
all possible error conditions and only act until you think all bases are
covered.
Some languages, like Python, make it easy to use this approach. When
Monitors were introduced, RPG did too, with the minor inconvenient of
spamming the job log.
--
Saludos
Antonio Salazar
As an Amazon Associate we earn from qualifying purchases.