• Subject: Re: Overflow values
  • From: John Hall <jhall@xxxxxxxxxxx>
  • Date: Wed, 23 Dec 1998 09:50:33 -0500

Nice example but this method of error handling is pitiful.  IBM needs to
improve it dramatically.  CL does a much better job of error trapping. 
Many of the PC languages also allow for usefull error trapping

ex:

try
  a := b / c;
except
  a := 0; 
  error := TRUE;
end;

or any number of other ways.  Even a monmsg opcode would be much better.


John Hall
Home Sales Co.

Vanya Jovic wrote:
> 
> Buck,
> 
> what is that GOTO :)))))? Oh, wait, rings a bell, Commodore C-64 and these
> high school days, BASIC & puberty.
> 
> Seriously, this is a good experimental example, but I think IBM should
> give us something better to trick a cycle in the real world.
> 
> Best regards,
> 
> Vanay Jovic,
> Canada
> 
> On Tue, 22 Dec 1998, Buck Calabro/commsoft wrote:
> 
> >
> >
> > >>While using EVAL for computing numbers, if the
> > >>result of computing gets larger than the result
> > >>field definition, the throws up an error.  Is
> > >>there any way to get around this?  Like say
> > >>truncate (as it does in Move) some EVAL(T)?? :)
> >
> > No.  EVAL will always behave like this, which is
> > probably a good thing, otherwise you are losing
> > precision in your calculated values and don't
> > know it!  If you really want to lose data, you'll
> > have to stick with ADD/SUB/MULT/DIV.
> >
> > >>If I use *PSSR, the program goes to the top of the line
> > >>and I loose all the work that is done till then.
> >
> > You can set up calculations in your *PSSR that check for
> > the type of error and set a flag.  When you ENDSR *DETC,
> > you can check the flag at the top of the detail calcs
> > and start processing at the appropriate place.
> >
> > Here's a poor example of what I mean:
> >
> > H Debug
> >
> >  * Sample code to demonstrate use of *PSSR directing
> >  * traffic after an error occurs
> >
> >  * Global declarations
> > D ErrFlag         S              1    Inz('N')
> > D ErrAction       S              6    Inz('*DETC ')
> > D CurrRoutine     S             10    Inz
> >
> >  * Test numbers
> > D Positive        S              5S 0 Inz(15)
> > D Negative        S              5S 0 Inz(-15)
> > D Zero            S              5S 0 Inz(0)
> > D PI              S             10S 9 Inz(3.141592654)
> > D Result          S              3S 0 Inz(0)
> >
> >  * Routine names describe where we are in the program
> >  * When an error occurs, we can steer ourselves
> >  * back to the appropriate place in the program
> > D RtnAdd          S             10    Inz('Add       ')
> > D RtnSub          S             10    Inz('Sub       ')
> > D RtnMul          S             10    Inz('Mul       ')
> > D RtnDiv          S             10    Inz('Div       ')
> >
> > D                SDS
> > D  PGNAME           *PROC
> > D  STATUS           *STATUS
> > D  TMNAME               244    253
> > D  USRNAM               254    263
> > D  JOBNBR               264    269  0
> >
> >  * Mainline.  This is just simple code to demonstrate
> >  * how we can direct traffic after an error occurs
> >  * The *PSSR traps the error, gets control and then
> >  * returns to this point in the program.
> >  *    *DETC         Tag
> >  * Did an error occur?  If so, recover!
> >  * For example's sake, only test/recover from an error
> >  * in the division routine
> >
> > C                   If        ErrFlag='Y'
> > C                   Eval      ErrFlag='N'
> > C                   Select
> > C                   When      CurrRoutine = RtnAdd
> > C                   GoTo      Add
> > C                   When      CurrRoutine = RtnSub
> > C                   GoTo      Sub
> > C                   When      CurrRoutine = RtnMul
> > C                   GoTo      Mul
> > C                   When      CurrRoutine = RtnDiv
> > C                   Eval      Result=0
> > C                   GoTo      PastDiv
> > C                   Other
> > C                   Dump
> > C                   EndSl
> > C                   EndIf
> >
> > C     Add           Tag
> > C                   Eval      CurrRoutine=RtnAdd
> > C                   Eval      Result=Zero+1
> >
> > C     Sub           Tag
> > C                   Eval      CurrRoutine=RtnSub
> > C                   Eval      Result=Zero-1
> >
> > C     Mul           Tag
> > C                   Eval      CurrRoutine=RtnMul
> > C                   Eval      Result=Zero*1
> >
> > C     Div           Tag
> > C                   Eval      CurrRoutine=RtnDiv
> > C                   Eval      Result=PI/Zero
> > C     PastDiv       Tag
> >
> > C                   Eval      *InLR=*On
> >
> >  * An error has occurred
> >  * Set the "Error is happening" flag and return to the mainline
> > C     *PSSR         BegSR
> > C                   Eval      ErrFlag='Y'
> > C                   EndSR     ErrAction
> >
> > Buck Calabro
> > CommSoft, Albany, NY
> > mailto:mcalabro@commsoft.net
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.