[Progress Communities] [Progress OpenEdge ABL] Forum Post: How to catch this error?

  • Thread starter Thread starter jamesmc
  • Start date Start date
Status
Not open for further replies.
J

jamesmc

Guest
Hi, I use the below code and I can successfully catch the error 98 that is raised (unable to open file).. DEFINE VARIABLE lvMessage AS CHARACTER NO-UNDO. DEFINE STREAM strFile. MAINBLOCK: DO ON ERROR UNDO, LEAVE: ASSIGN lvMessage = "". OUTPUT STREAM strFile TO VALUE( "c:\tempr\blah.txt" ). OUTPUT STREAM strFile CLOSE. CATCH lvError AS Progress.Lang.Error: ASSIGN lvMessage = SUBSTITUTE("Caught! &1", lvError:GetMessage(1) ). END CATCH. END. /* MAINBLOCK */ MESSAGE lvMessage VIEW-AS ALERT-BOX INFO BUTTONS OK. But when I change the code to the below I no longer get the message from the catch block, instead the program errors... DEFINE TEMP-TABLE ttList NO-UNDO FIELD tDate AS DATE FIELD tSeq AS INTEGER FIELD tText AS CHARACTER INDEX tabix IS PRIMARY tDate tSeq. DEFINE VARIABLE lvMessage AS CHARACTER NO-UNDO. DEFINE STREAM strFile. /************************************/ CREATE ttList. ASSIGN ttList.tDate = TODAY ttList.tSeq = 1 ttList.tText = "A". CREATE ttList. ASSIGN ttList.tDate = TODAY ttList.tSeq = 2 ttList.tText = "B". CREATE ttList. ASSIGN ttList.tDate = TODAY ttList.tSeq = 3 ttList.tText = "C". /************************************/ MAINBLOCK: DO ON ERROR UNDO, LEAVE: ASSIGN lvMessage = "". FOR EACH ttList NO-LOCK BREAK BY ttList.tDate BY ttList.tSeq: IF FIRST-OF(ttList.tDate) THEN DO: OUTPUT STREAM strFile TO VALUE( SUBSTITUTE("c:\tempr\&1.txt", ttList.tSeq) ). END. PUT STREAM strFile UNFORMATTED ttList.tText SKIP. IF LAST-OF(ttList.tDate) THEN DO: OUTPUT STREAM strFile CLOSE. END. END. CATCH lvError AS Progress.Lang.Error: ASSIGN lvMessage = lvError:GetMessage(1). END CATCH. END. /* MAINBLOCK */ MESSAGE lvMessage VIEW-AS ALERT-BOX INFO BUTTONS OK. How is the catch not working in the second example? Windows 7, OE 10.2B08 Thanks

Continue reading...
 
Status
Not open for further replies.
Back
Top