REM > JLibraries:Debug.2
REM © James Bursa, 1997

REM JB  20 Nov 1997     created


DEF PROCBUG(Text$)
LOCAL PFlg%, File%

 IF FNWimp_FileExists("Debug") THEN
  File% = OPENUP("Debug")
  PTR#File% = EXT#File%
  BPUT#File%, Text$
  CLOSE#File%
 ENDIF

SYS"XOS_SWINumberFromString",, "DDEUtils_ThrowbackStart" TO ;PFlg%
IF (PFlg% AND 1) THEN ENDPROC

SYS"XDDEUtils_ThrowbackStart"
SYS"XDDEUtils_ThrowbackSend", 0,, Task_Name$
SYS"XDDEUtils_ThrowbackSend", 2,, Task_Name$, 0, 0, Text$
SYS"XDDEUtils_ThrowbackEnd"

ENDPROC

REM ˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜

DEF FNWimp_Error
LOCAL Quit%, Text$, T%, T$, PFlg%
LOCAL ERROR
ON ERROR LOCAL ON ERROR OFF: ERROR 0, (REPORT$+" in Error Handler (Code "+STR$ERL+"); must exit.")

SYS"Hourglass_Smash"

 IF Erro_ERR% = -1 THEN
  Erro_ERR%    = ERR
  Erro_ERL%    = ERL
  Erro_REPORT$ = REPORT$
 ENDIF

 CASE Erro_ERR% OF

  WHEN Erro_Memo%
   Quit% = FNWimp_ReportError(Erro_Memo$, Erro_Warn%)

  WHEN Erro_Info%, Erro_Warn%
    IF LEFT$(Erro_REPORT$, 1) = "%" THEN
     Erro_REPORT$ = FNMess_Lookup(MID$(Erro_REPORT$, 2), File_Mess%)
    ENDIF
   Quit% = FNWimp_ReportError(Erro_REPORT$, Erro_ERR%)

  OTHERWISE
    IF Task_ThrowBack% THEN
     SYS"XOS_SWINumberFromString",, "DDEUtils_ThrowbackStart" TO ;PFlg%
      IF (PFlg% AND 1) = 0 THEN
       T$ = "<"+Task_Name$+"$RunImage>"
       T% = INSTR(Erro_REPORT$,"in """)
       IF T% THEN T$ = MID$(Erro_REPORT$, T% + 4, LENErro_REPORT$ - T% - 4)
       SYS"XDDEUtils_ThrowbackStart"
       SYS"XDDEUtils_ThrowbackSend", 0,, T$
       SYS"XDDEUtils_ThrowbackSend", 1,, T$, Erro_ERL%, 1, Erro_REPORT$+" (Code &"+STR$~Erro_ERR%+")"
       SYS"XDDEUtils_ThrowbackEnd"
      ENDIF
    ENDIF
   @% = "+g20.20"
   SYS"WimpExt_SubstituteArgs", Erro_Erro$, B%, Erro_REPORT$, STR$Erro_ERL%, STR$~Erro_ERR%, 0, 0 TO ,Text$
   Quit% = FNWimp_ReportError(Text$, 1)
   IF Quit% THEN Quit% = FNWimp_ReportError(Erro_Quit$, Erro_Ques%)

 ENDCASE

Erro_ERR% = -1

=Quit%
