home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1995 September / Image.iso / visualob / install / samples / errorsys.pr_ / errorsys.pr
Encoding:
Text File  |  1995-01-02  |  21.7 KB  |  765 lines

  1. STATIC DEFINE CALL_PROC :=2
  2. STATIC DEFINE CUR_PROC  :=1
  3. STATIC DEFINE FILE_ERRORLOG     :="VOERROR.LOG"
  4.  
  5. STATIC DEFINE TXT_SEP :="   "
  6.  
  7. STATIC DEFINE TXT_VERSION:="LB 03/28/94"
  8.  
  9. STATIC FUNCTION DefError(oError AS OBJECT) AS USUAL PASCAL
  10.  
  11.   LOCAL DIM awButton[3] AS WORD
  12.   LOCAL wChoice AS WORD
  13.   LOCAL cTitel AS STRING
  14.   LOCAL cMessage AS STRING
  15.   LOCAL lErrorLog AS LOGIC
  16.   LOCAL cFileErrorLog AS STRING
  17.   LOCAL siFEL AS SHORTINT
  18.   LOCAL siI AS SHORTINT
  19.   LOCAL cDiskName AS STRING
  20.   LOCAL cCurDiskName AS STRING
  21.   LOCAL lOsError AS LOGIC
  22.   LOCAL siFError, siDOSError AS SHORTINT
  23.   LOCAL cBuffer AS STRING
  24.   LOCAL aDynStack AS ARRAY
  25.   LOCAL siDynStack AS SHORTINT
  26.   LOCAL dwFilePos AS DWORD
  27.   LOCAL pszDrive AS PSZ
  28.   LOCAL lDangerous AS LOGIC
  29.   LOCAL strucMArgs AS _MARGS
  30.   LOCAL aArgs AS ARRAY
  31.   LOCAL wCount, wI, wJ AS WORD
  32.   LOCAL oSelf AS OBJECT
  33.   LOCAL p AS PTR
  34.   LOCAL symIVar AS SYMBOL
  35.   LOCAL cMessageLine1 AS STRING
  36.   LOCAL cMessageLine3 AS STRING
  37.   LOCAL cMessageLine5 AS STRING
  38.   LOCAL cFormat AS STRING
  39.  
  40.   STATIC LOCAL wDefError AS WORD
  41.  
  42.   ~"PROCLINE+"
  43.   ~"PROCNAME+"
  44.  
  45.   IF .NOT. IsInstanceOf(oError, #ERROR)
  46.     ClearStrucErrInfo()
  47.     strucErrInfo.wGenCode    := EG_WRONGCLASS
  48.   strucErrInfo.wSeverity   := ES_ERROR
  49.     strucErrInfo.symFuncSym  := #DefError
  50.     strucErrInfo.pszArg              := AsPsz(oError)
  51.     strucErrInfo.wArgNum     := 1
  52.     strucErrInfo.lCanDefault := .T.
  53.     oError :=ErrorBuild(@strucErrInfo)
  54.   ENDIF
  55.  
  56.   IF oError:CanDefault
  57.     IF oError:GenCode = EG_OPEN .AND.;
  58.        oError:OsCode  = 32
  59.       NetErr(.T.)
  60.       RETURN E_DEFAULT
  61.     ENDIF
  62.  
  63.     IF oError:GenCode = EG_APPENDLOCK
  64.       NetErr(.T.)
  65.       RETURN E_DEFAULT
  66.     ENDIF
  67.   ENDIF
  68.  
  69.   IF ++wDefError >=3
  70.     _IError(oError:GenCode, .T., __CavoStr(__CAVOSTR_SYSLIB_ERR_IN_ERR))
  71.   ELSEIF wDefError >=2
  72.     p :=_MAKEPTR(_SS, 0x56)
  73.     WORD(p) :=2
  74.   ENDIF
  75.  
  76.   siFError   :=FError()
  77.   siDOSError :=DOSError()
  78.  
  79.   IF SetBeep()
  80.     Tone(440, 1)
  81.     Tone(494, 1)
  82.     Tone(523, 1)
  83.   ENDIF
  84.  
  85.   IF oError:GenCode = EG_MEM
  86.   ELSE
  87.     DynLock()
  88.   ENDIF
  89.  
  90.   IF oError:CanDefault .OR. oError:CanSubstitute
  91.     awButton[1] := SE_IGNORE
  92.   ENDIF
  93.   IF oError:CanRetry
  94.     IF oError:GenCode = EG_NOVAR
  95.       oError:CanRetry :=.F.
  96.     ELSE
  97.       awButton[2] := SE_RETRY
  98.     ENDIF
  99.   ENDIF
  100.  
  101.  
  102.  
  103.   awButton[3] := IIF(CanBreak(), SE_CANCEL +SE_DEFAULT, SE_ABORT +SE_DEFAULT)
  104.  
  105.  
  106.      ;
  107.  
  108.  
  109.     cTitel := __CavoStr(__CAVOSTR_SYSLIB_MODULE)
  110.     cMessageLine1 := VO_SPrintF(cTitel, ProcFile(CUR_PROC) +"  ")
  111.  
  112.           ;
  113.  
  114.     cTitel := __CavoStr(__CAVOSTR_SYSLIB_ENTITY)
  115.     cMessageLine3 := VO_SPrintF(cTitel, ProcName(CUR_PROC) +"  ")
  116.     IF ProcLine(CUR_PROC) <>0
  117.       cTitel := __CavoStr(__CAVOSTR_SYSLIB_LINE)
  118.       cMessageLine5 := VO_SPrintF(cTitel, " " + NTrim(ProcLine(CUR_PROC)))
  119.     ENDIF
  120.  
  121.     cTitel := cMessageLine1 + cMessageLine3 + cMessageLine5
  122.  
  123.  
  124.  
  125.   IF oError:SubstituteType =PTR
  126.     oError:Severity := ES_CATASTROPHIC
  127.   ENDIF
  128.  
  129.   cMessage :=ErrorMessage(oError)
  130.  
  131.   IF SetErrorLog()
  132.     lOsError  :=siFError <>0 .OR.siDOSError <>0 .OR.oError:OsCode <>0
  133.     lErrorLog :=.T.
  134.  
  135.     IF !GetDefaultDir() ==""
  136.       cFileErrorLog :=GetDefaultDir()
  137.     ELSE
  138.       cFileErrorLog :=GetDefault()
  139.     ENDIF
  140.  
  141.     SplitPath(cFileErrorLog, pszDrive, NULL_PSZ, NULL_PSZ, NULL_PSZ)
  142.     IF GetDriveType(Asc(UpperA(pszDrive) +DiskName()) -65) <>DRIVE_FIXED .AND.;
  143.        GetDriveType(2) =DRIVE_FIXED
  144.       cFileErrorLog :="C:"
  145.     ENDIF
  146.  
  147.     IF ErrorCount() =1
  148.       wI :=GetProfileInt(INI_GROUP_RUNTIME, "ErrorLogAppend", 2)
  149.       IF wI >1
  150.         wI :=0
  151.         WriteProfileString(INI_GROUP_RUNTIME, "ErrorLogAppend", "0")
  152.       ENDIF
  153.     ELSE
  154.       wI :=1
  155.     ENDIF
  156.  
  157.  
  158.     DO WHILE .T.
  159.       cFileErrorLog +=FILE_ERRORLOG
  160.       IF wI =1
  161.         siFEL :=FOpen2(cFileErrorLog, FO_WRITE)
  162.       ELSE
  163.         siFEL :=F_ERROR
  164.       ENDIF
  165.  
  166.       IF siFEL <>F_ERROR
  167.         FSeek3(siFEL, 0, FS_END)
  168.         Write3(siFEL, "", 0)
  169.       ELSE
  170.         siFEL :=FCreate2(cFileErrorLog, FC_NORMAL)
  171.         IF FError() =3
  172.           cFileErrorLog :=""
  173.           IF !GetDefaultDir() ==""
  174.             cBuffer :="SetDefaultDir: " +GetDefaultDir()
  175.             SetDefaultDir("")
  176.           ELSE
  177.             cBuffer :="SetDefault: " +GetDefault()
  178.             SetDefault("")
  179.           ENDIF
  180.  
  181.           _IError(EG_ARG, .F., cBuffer)
  182.           LOOP
  183.         ENDIF
  184.       ENDIF
  185.       EXIT
  186.     ENDDO
  187.  
  188.     IF siFEL <>F_ERROR
  189.       cBuffer :=Replicate("*", 60) +Str(ErrorCount(), 12)
  190.       _Hex(_GetInst(), PTR(_CAST, LONG(_CAST, cBuffer)+61))
  191.       cFormat := __CavoStr(__CAVOSTR_SYSLIB_ERROR)
  192.       cMessageLine1 := VO_SPrintF(cFormat, cBuffer)
  193.       Write2(siFEL, cMessageLine1)
  194.  
  195.       Write2(siFEL, Version())
  196.       Write2(siFEL, TXT_VERSION)
  197.       Write2(siFEL, DtoC(Today()) +TXT_SEP +Time();
  198.         +TXT_SEP +TString(GetTickCount() /1000))
  199.  
  200.       cFormat := __CavoStr(__CAVOSTR_SYSLIB_MODULE)
  201.       cMessageLine1 := VO_SPrintF(cFormat, "")
  202.  
  203.       cFormat := __CavoStr(__CAVOSTR_SYSLIB_LINE)
  204.       cMessageLine3 := VO_SPrintF(cFormat, "")
  205.  
  206.       cFormat := __CavoStr(__CAVOSTR_SYSLIB_ENTITY)
  207.       cMessageLine5 := VO_SPrintF(cFormat, "")
  208.  
  209.       Write2(siFEL, Space(7);
  210.          ;
  211.         +PadR(cMessageLine1, 18) +"  ";
  212.          ;
  213.         +PadL(cMessageLine3,  7) +"  ";
  214.          ;
  215.         +     cMessageLine5)
  216.       FOR siI := _MaxAS() DOWNTO CUR_PROC
  217.         Write2(siFEL, Str(siI, 5) +": ";
  218.           +PadR(ProcFile(siI), 18) +"  ";
  219.           +Str( ProcLine(siI),  7) +"  ";
  220.           +     ProcName(siI))
  221.         IF InStr(":", ProcName(siI))
  222.           strucMArgs :=MAKEPTR(_SS,_ProcBP(siI) +6)
  223.           wCount :=MAX(strucMArgs.bPCount,;
  224.                  strucMArgs.bArgCount)
  225.           IF wCount >0
  226.             aArgs := ArrayInit(wCount, @strucMArgs.ptrData)
  227.             FOR wJ := 1 UPTO wCount
  228.               Write2(siFEL, Str(wJ,11) +": ";
  229.                 +PadR(TypeString(UsualType(aArgs[wJ])), 12);
  230.                 +LString(aArgs[wJ]))
  231.             NEXT
  232.           ENDIF
  233.           oSelf :=OBJECT(_CAST, strucMArgs.ptrSelf)
  234.           Write2(siFEL, "       SELF: " +_AsString(oSelf))
  235.         ENDIF
  236.       NEXT
  237.       
  238.       Write2(siFEL, StrTran(cMessage, _CHR(ASC_LF), CrLf))
  239.  
  240.       IF oError:FuncPtr <>NULL_PTR
  241.          ;
  242.         cFormat := __CavoStr(__CAVOSTR_SYSLIB_FUNCPTR)
  243.         cMessageLine1 := VO_SPrintF(cFormat, AsString(oError:FuncPtr), Symbol2String(FunctionPtr2Sym(oError:FuncPtr)))
  244.  
  245.         Write2(siFEL, cMessageLine1)
  246.       ENDIF
  247.       IF ALen(oError:Args) >0
  248.         Write2(siFEL, __CavoStr(__CAVOSTR_SYSLIB_ARGS))
  249.         FOR wI :=1 UPTO ALen(oError:Args)
  250.           cBuffer :=Str(wI, 3) +": "
  251.           IF IsNIL(oError:Args[wI])
  252.             cBuffer +="NIL"
  253.           ELSE
  254.             cBuffer +=;
  255.             +PadR(TypeString(UsualType(oError:Args[wI])), 12);
  256.             +LString(oError:Args[wI])
  257.           ENDIF
  258.           Write2(siFEL, cBuffer)
  259.         NEXT
  260.       ENDIF
  261.  
  262.       lDangerous :=InList(oError:GenCode,;
  263.                 EG_PROTECTION,;
  264.                 EG_STACK,;
  265.                 EG_CORRUPTION) .OR.;
  266.              DynCheckError() <>0
  267.  
  268.       IF !lDangerous
  269.         Write3(siFEL, "DynStack2Array():", 17)
  270.         aDynStack :=DynStack2Array()
  271.         siDynStack :=AScan(aDynStack, oError, -1, -0xFFFF) -1
  272.         siDynStack :=AScan(aDynStack, oError, siDynStack, -0xFFFF) -1
  273.         FOR siI :=1 TO siDynStack
  274.           Write2(siFEL, LString(aDynStack[siI]))
  275.         NEXT
  276.       ENDIF
  277.  
  278.       IF !IsNIL(SysObject())
  279.         Write2(siFEL, "SysObject()   " +_AsString(SysObject()))
  280.       ENDIF
  281.  
  282.       IF !Alias0() ==""
  283.         Write2(siFEL, "Alias0(): " +Alias0())
  284.         FOR wJ := 1 UPTO FCount()
  285.           Write2(siFEL,;
  286.             +PadR(FieldName(wJ), 23);
  287.             +": ";
  288.             +LString(FieldGetSym(FieldSym(wJ))))
  289.         NEXT
  290.       ENDIF
  291.  
  292.       IF !InList(oError:GenCode,;
  293.           EG_DATATYPE,;
  294.           EG_NOVAR,;
  295.           EG_UNSUPPORTED,;
  296.           EG_ZERODIV,;
  297.           EG_SYNTAX)
  298.         Write2(siFEL, "Memory():")
  299.         aDynStack :={;
  300.           "SYSTEM_FREE",;
  301.           "SYSTEM_MAX",;
  302.           "DYNINFOFREE",;
  303.           "DYNINFOMAX",;
  304.           "RT_DGROUP_SIZE",;
  305.           "RT_DS_SIZE",;
  306.           "STACK_SIZE",;
  307.           "STACK_FREE",;
  308.           "MAXATOM",;
  309.           "ACTIVATION",;
  310.           "PUBLIC",;
  311.           "PRIVAT",;
  312.           "DYNINFOUSED",;
  313.           "MEMTOTAL",;
  314.           "DS_SIZE",;
  315.           "CS_SIZE",;
  316.           "REGISTEREXIT_COUNT",;
  317.           "REGCOLLNOTIFYSTART_COUNT",;
  318.           "REGCOLLNOTIFYEND_COUNT",;
  319.           "REGISTERKID",;
  320.           "REGISTERAXIT",;
  321.           "COLLECTCOUNT",;
  322.           "DYNINFOSIZE",;
  323.           "RT_DGROUP",;
  324.           "RT_DS",;
  325.           "SS",;
  326.           "DS",;
  327.           "CS",;
  328.           "SEQUENCE",;
  329.           "STACKKID",;
  330.           "SP",;
  331.           "GLOBALSEL",;
  332.           "FUNCTIONCOUNT",;
  333.           "CLASSCOUNT",;
  334.           "DB_DS",;
  335.           "DB_DS_SIZE"}
  336.         FOR wI := 0 UPTO 35
  337.           IF InList(wI,4,5,6,7,8,9,10,11,14,15,23,24,25,26,27,28,30,34,35)
  338.             IF Memory(wI) >=0x10000
  339.               cBuffer :=":    0x00000000"
  340.               _Hex(Memory(wI) /0x10000, PTR(_CAST, LONG(_CAST, cBuffer)+7))
  341.             ELSE
  342.               cBuffer :=":        0x0000"
  343.             ENDIF
  344.             _Hex(Memory(wI) %0x10000, PTR(_CAST, LONG(_CAST, cBuffer)+11))
  345.           ELSE
  346.             cBuffer :=":" +Str(Memory(wI), 14)
  347.           ENDIF
  348.           Write2(siFEL, Str(wI, 3) +cBuffer +" " +aDynStack[wI+1])
  349.         NEXT
  350.  
  351.         Write2(siFEL, "100:"+Str(Memory(100), 4) +"% SYSTEM resources")
  352.         Write2(siFEL, "101:"+Str(Memory(101), 4) +"% GDI resources")
  353.         Write2(siFEL, "102:"+Str(Memory(102), 4) +"% USER resources")
  354.  
  355.         Write3(siFEL, "GetNumTasks()  ";
  356.               +Str(GetNumTasks()  , 3), 18)
  357.         Write3(siFEL, "SetCPU()       ";
  358.               +Str(SetCPU()       , 3), 18)
  359.         Write3(siFEL, "SetMath()      ";
  360.               +Str(SetMath()           , 3), 18)
  361.         IF !_MathCheck()
  362.           Write3(siFEL, "_MathCheck()   F", 16)
  363.         ENDIF
  364.         IF InCollect()
  365.           Write3(siFEL, "InCollect()    T", 16)
  366.         ENDIF
  367.  
  368.         IF !lDangerous
  369.           Write3(siFEL, "_DynCheck()    ";
  370.                +LtoC(_DynCheck())   , 16)
  371.         ENDIF
  372.         IF DynCheckError() <>0
  373.           Write2(siFEL, "DynCheckError()";
  374.                 +Str(DynCheckError(), 3);
  375.                 +Str(DynCheckErrorInfo(), 3);
  376.                 +" " +Symbol2String(DynCheckErrorSym()))
  377.         ENDIF
  378.         Write3(siFEL, "_GetRTCount()  ";
  379.               +Str(_GetRTCount()  , 3), 18)
  380.         Write3(siFEL, "_GetRTNum()    ";
  381.               +Str(_GetRTNum()    , 3), 18)
  382.         IF NetErr()
  383.           Write3(siFEL, "NetErr()       T", 16)
  384.         ENDIF
  385.         IF !Empty(NetName())
  386.           Write2(siFEL, "NetName()      " +NetName())
  387.         ENDIF
  388.         IF ErrorLevel() <>0
  389.           Write3(siFEL, "ErrorLevel()   ";
  390.                 +Str(ErrorLevel()   , 3), 18)
  391.         ENDIF
  392.         Write2(siFEL, "GetDOSError()  ";
  393.               +Str(GetDOSError()  , 3);
  394.               +TXT_SEP +DOSErrString(GetDOSError()))
  395.  
  396.         p :=_MAKEPTR(_SS, 0x2A)
  397.         wJ :=WORD(p)
  398.         Write2(siFEL, "ErrorAct()     " +Str(wJ, 3))
  399.         p :=_MAKEPTR(_SS, 0x2C)
  400.         wJ :=WORD(p)
  401.         Write2(siFEL, "ErrorOrg()     " +Str(wJ, 3))
  402.         p :=_MAKEPTR(_SS, 0x76)
  403.         wJ :=WORD(p)
  404.         Write2(siFEL, "ErrorBase()    " +Str(wJ, 3))
  405.  
  406.         IF siDOSError <>0
  407.           Write2(siFEL, "DOSError()     ";
  408.               +Str(siDOSError     , 3);
  409.               +TXT_SEP +DOSErrString(siDOSError))
  410.         ENDIF
  411.         IF siFError <>0
  412.           Write2(siFEL, "FError()       ";
  413.               +Str(siFError       , 3);
  414.               +TXT_SEP +DOSErrString(siFError))
  415.         ENDIF
  416.         Write2(siFEL, "OS()           " +OS())
  417.         IF !FPathName() ==""
  418.           Write2(siFEL, "FPathName()    " +FPathName())
  419.         ENDIF
  420.         IF !GetDefaultDir() ==""
  421.           Write2(siFEL, "GetDefaultDir()" +GetDefaultDir())
  422.         ENDIF
  423.         IF !GetDefault() ==""
  424.           Write2(siFEL, "GetDefault()   " +GetDefault())
  425.         ENDIF
  426.         IF !GetPath() ==""
  427.           Write2(siFEL, "GetPath()      " +GetPath())
  428.         ENDIF
  429.         Write3(siFEL, "PATH=", 5)
  430.         Write2(siFEL, GetEnv("PATH"))
  431.  
  432.         cBuffer :=Buffer(128)
  433.         Write2(siFEL, "GetWindowsDirectory(): ";
  434.          +Left(cBuffer,GetWindowsDirectory(cBuffer, 128)))
  435.  
  436.         Write2(siFEL, "GetSystemDirectory():  ";
  437.          +Left(cBuffer,GetSystemDirectory(cBuffer, 128)))
  438.  
  439.         Write2(siFEL, "GetModuleFileName():   ";
  440.          +Left(cBuffer,GetModuleFileName(_GetInst(), PTR(_CAST, cBuffer), 128)))
  441.  
  442.         IF !Empty(_GetCmdLine())
  443.           cFormat := __CavoStr(__CAVOSTR_SYSLIB_CMD_LINE)
  444.           cMessageLine1 := VO_SPrintF(cFormat, _GetCmdLine())
  445.  
  446.           Write2(siFEL, cMessageLine1)
  447.         ENDIF
  448.  
  449.         Write2(siFEL, "[" +INI_GROUP_RUNTIME +"]")
  450.         wI :=GetProfileInt(INI_GROUP_RUNTIME, "DynamicMemory", 0)
  451.         p :=_MAKEPTR(_SS, 0x86)
  452.         wJ :=WORD(p)
  453.         Write3(siFEL, "DynamicMemory= ";
  454.                    +Str(wI, 3);
  455.                    +Str(wJ, 5), 23)
  456.         wI :=GetProfileInt(INI_GROUP_RUNTIME, "Trap", 0)
  457.         p :=_MAKEPTR(_SS, 0x56)
  458.         wJ :=WORD(p)
  459.         Write3(siFEL, "Trap=          ";
  460.                    +Str(wI, 3);
  461.                    +Str(wJ, 5), 23)
  462.  
  463.         IF lOsError
  464.           cCurDiskName :=DiskName()
  465.            ;
  466.           Write2(siFEL, PadR(__CavoStr(__CAVOSTR_SYSLIB_DISK), 4) +" ";
  467.                   ;
  468.                  +PadL(__CavoStr(__CAVOSTR_SYSLIB_DISK_FREE), 8);
  469.                   ;
  470.                  +__CavoStr(__CAVOSTR_SYSLIB_CURDIR))
  471.           FOR wI := 0 UPTO 26
  472.             IF GetDriveType(wI) =DRIVE_FIXED
  473.               cDiskName :=CHR(65 +wI)
  474.               IF DiskChange(cDiskName)
  475.                 Write2(siFEL,;
  476.                    IIF(cDiskName ==cCurDiskName, "*", " ");
  477.                   +cDiskName +":";
  478.                   +Str(DiskFree(), 10);
  479.                   +" ";
  480.                   +CurDir())
  481.               ENDIF
  482.             ENDIF
  483.           NEXT
  484.           DiskChange(cCurDiskName)
  485.  
  486.            ;
  487.           Write2(siFEL, PadR(__CavoStr(__CAVOSTR_SYSLIB_HANDLE), 3) +" ";
  488.                   ;
  489.                  +PadL(__CavoStr(__CAVOSTR_SYSLIB_HANDLE_END), 14) +" ";
  490.                   ;
  491.                  +PadL(__CavoStr(__CAVOSTR_SYSLIB_HANDLE_CUR), 14))
  492.           FOR siI := 5 UPTO 255
  493.             IF siI <>siFEL
  494.               dwFilePos :=FTell(siI)
  495.               IF FSeek3(siI, 0L, SEEK_END) >0
  496.                 Write3(siFEL, Str(siI, 3) +":";
  497.                        +Str(FTell(siI), 14);
  498.                        +Str(dwFilePos, 15), 33)
  499.                 FSeek3(siI, dwFilePos, SEEK_SET)
  500.               ENDIF
  501.             ENDIF
  502.           NEXT
  503.  
  504.         ENDIF
  505.       ENDIF
  506.       FClose(siFEL)
  507.     ENDIF
  508.  
  509.   ENDIF
  510.  
  511.   wChoice :=Min(oError:Choice, 3)
  512.  
  513.   IF wChoice =EC_ALERT .OR. awButton[wChoice] =0
  514.  
  515.  
  516.  
  517.     wChoice := ErrorMessageBox(STRTRAN(cMessage,"&","&&"), cTitel, awButton[1], awButton[2], awButton[3])
  518.   ENDIF
  519.  
  520.   IF lErrorLog
  521.     siFEL :=FOpen2(cFileErrorLog, FO_WRITE)
  522.     IF siFEL <>F_ERROR
  523.       FSeek3(siFEL, 0, FS_END)
  524.       cFormat := __CavoStr(__CAVOSTR_SYSLIB_CHOICE)
  525.       cMessageLine1 := VO_SPrintF(cFormat, Str(oError:Choice, 3) +Str(wChoice, 3) +TXT_SEP , Time())
  526.  
  527.       Write2(siFEL, cMessageLine1)
  528.       FClose(siFEL)
  529.     ENDIF
  530.   ENDIF
  531.  
  532.   IF oError:GenCode <>EG_MEM
  533.     DynUnLock()
  534.   ENDIF
  535.  
  536.   wDefError -=1
  537.   FError(  siFError)
  538.   DOSError(siDOSError)
  539.  
  540.   DO CASE
  541.   CASE wChoice =1
  542.     IF oError:CanSubstitute
  543.       RETURN EmptyUsual(oError:SubstituteType)
  544.     ELSE
  545.       RETURN E_DEFAULT
  546.     ENDIF
  547.   CASE wChoice =2
  548.     RETURN E_RETRY
  549.   ENDCASE
  550.  
  551.   _MathInit()
  552.   IF CanBreak()
  553.     BREAK oError
  554.   ENDIF
  555.  
  556.   ErrorLevel(oError:GenCode)
  557.   _Quit()
  558.  
  559. STATIC FUNCTION ErrorMessage(oError AS OBJECT) AS STRING PASCAL
  560.   LOCAL cMessage AS STRING
  561.   LOCAL sArg AS STRING
  562.   LOCAL wArgType AS WORD
  563.   LOCAL cSymbol  AS STRING
  564.   LOCAL cMessage1 AS STRING
  565.  
  566.   DO CASE
  567.   CASE oError:Severity = ES_WARNING
  568.     cMessage := __CavoStr(__CAVOSTR_SYSLIB_WARNING)
  569.   CASE oError:Severity = ES_CATASTROPHIC
  570.     cMessage := __CavoStr(__CAVOSTR_SYSLIB_DANGER)
  571.   ENDCASE
  572.  
  573.  
  574.   IF oError:GenCode <>0
  575.      cMessage  +=  " "+ErrString(oError:GenCode)
  576.   ENDIF
  577.  
  578.   IF !oError:SubSystem ==""
  579.     cMessage += TXT_SEP+vo_SPrintF(__CAVOSTR_SYSLIB_SUBSYSTEM,oError:SubSystem)
  580.   ENDIF
  581.  
  582.   if !empty(cMessage)
  583.       cMessage += TXT_SEP
  584.   endif
  585.  
  586.   IF oError:SubCode <>0
  587.     cMessage1  := NTrim(oError:SubCode)
  588.     IF !oError:SubCodeText ==""
  589.       cMessage1 += "("+oError:SubCodeText+")"
  590.     ENDIF
  591.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_SUBCODE, cMessage1) + TXT_SEP
  592.   ENDIF
  593.  
  594.   if !empty(cMessage)
  595.       cMessage += _chr(ASC_LF)
  596.   endif
  597.  
  598.   DO CASE
  599.   CASE oError:FuncSym <>NULL_SYMBOL
  600.     cSymbol :=Symbol2String(oError:FuncSym)
  601.     IF InStr("=>", cSymbol)
  602.       DO CASE
  603.       CASE cSymbol =="=>"
  604.         cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_CONVERSION," ")
  605.       CASE cSymbol = "=>"
  606.         cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_CONVERSION_TO,"USUAL",SubStr2(cSymbol, 3))
  607.       OTHERWISE
  608.         cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_CONVERSION,cSymbol)
  609.       ENDCASE
  610.     ELSE
  611.       cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_FUNCTION,cSymbol)
  612.     ENDIF
  613.     cMessage += TXT_SEP
  614.     IF oError:CallFuncSym <>NULL_SYMBOL .AND.oError:CallFuncSym <>oError:FuncSym
  615.       cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_CALLED_FROM,Symbol2String(oError:CallFuncSym))+TXT_SEP
  616.     ENDIF
  617.   CASE oError:CallFuncSym <>NULL_SYMBOL
  618.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_FUNCTION,Symbol2String(oError:CallFuncSym))+TXT_SEP
  619.   ENDCASE
  620.  
  621.   cMessage += _chr(ASC_LF)
  622.  
  623.   IF !oError:Description ==""
  624.     cMessage += oError:Description +TXT_SEP
  625.   ENDIF
  626.  
  627.   IF !oError:FileName ==""
  628.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_FILE,oError:FileName) + TXT_SEP
  629.   ENDIF
  630.  
  631.   IF !oError:Operation ==""
  632.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_OPERATION,oError:Operation) + TXT_SEP
  633.   ENDIF
  634.  
  635.   IF oError:CanRetry
  636.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_TRIES,NTrim(oError:Tries)) + TXT_SEP
  637.   ENDIF
  638.  
  639.   cMessage += _chr(ASC_LF)
  640.  
  641.   IF oError:OsCode <>0
  642.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_DOS_ERROR,NTrim(oError:OsCode)+" ("+DOSErrString(oError:OsCode) +")") + TXT_SEP
  643.   ENDIF
  644.  
  645.   IF oError:FileHandle <>0
  646.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_FILE_HANDLE,NTrim(oError:FileHandle)) + TXT_SEP
  647.   ENDIF
  648.  
  649.   cMessage += _chr(ASC_LF)
  650.  
  651.   wArgType :=oError:ArgType
  652.   sArg     :=Left(oError:Arg, 40)
  653.   IF oError:ArgNum <>0
  654.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_ARGNUM,NTrim(oError:ArgNum)) + TXT_SEP
  655.     IF oError:ArgNum < =ALen(oError:Args)
  656.       wArgType:=UsualType(oError:Args[oError:ArgNum])
  657.       sArg    :=LString(oError:Args[oError:ArgNum])
  658.     ENDIF
  659.   ENDIF
  660.  
  661.   IF !sArg ==""
  662.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_ARG,sArg) + TXT_SEP
  663.   ENDIF
  664.  
  665.   IF wArgType <>0
  666.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_ARGTYPE,TypeString(wArgType)) + TXT_SEP
  667.   ENDIF
  668.  
  669.   IF oError:ArgTypeReq <>0 .AND. oError:ArgTypeReq <>oError:ArgType
  670.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_ARGTYPE_REQ,TypeString(oError:ArgTypeReq)) + TXT_SEP
  671.   ENDIF
  672.  
  673.   IF oError:MaxSize <>0 .OR. oError:GenCode = EG_BOUND
  674.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_MAX,NTrim(oError:MaxSize)) + TXT_SEP
  675.   ENDIF
  676.  
  677.   cMessage += _chr(ASC_LF)
  678.  
  679.   IF oError:MethodSelf <>NULL_OBJECT
  680.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_OBJECT,_AsString(oError:MethodSelf)) + TXT_SEP
  681.   ENDIF
  682.  
  683.   IF oError:CanSubstitute
  684.     cMessage += VO_SPrintF(__CAVOSTR_SYSLIB_SUBST_TYPE,TypeString(oError:SubstituteType)) + TXT_SEP
  685.   ENDIF
  686.  
  687.   RETURN cMessage
  688.  
  689. PROC ERRORSYS AS VOID PASCAL _INIT1
  690.   ErrorBlock( {|oError| DefError(oError)} )
  691. STATIC FUNCTION LString(x AS USUAL) AS STRING PASCAL
  692.   LOCAL cRet AS STRING
  693.   LOCAL bSaveHandler AS CODEBLOCK
  694.   LOCAL oError AS USUAL
  695.  
  696.   bSaveHandler :=ErrorBlock( {|o|_Break(o)})
  697.  
  698.   BEGIN SEQUENCE
  699.     cRet :=Left(_AsString(x), 40)
  700.     IF UsualType(x) =WORD(_CAST, ARRAY)
  701.       cRet +=" " +ADimPic(x)
  702.       cRet +=" APageCount() " +NTrim(APageCount(x))
  703.     ENDIF
  704.  
  705.   RECOVER USING oError
  706.  
  707.     cRet :=__CavoStr(__CAVOSTR_SYSLIB_ARG_ERROR)
  708.   END SEQUENCE
  709.  
  710.   ErrorBlock(bSaveHandler)
  711.  
  712.   RETURN cRet
  713. _DLL FUNC voerror10_sprintf(          ;
  714.     outputString AS PSZ, ;
  715.     format AS STRING, ;
  716.     v1 as STRING,          ;
  717.   v2 as STRING,       ;
  718.   v3 as STRING,        ;
  719.   v4 as STRING,        ;
  720.   v5 as STRING,        ;
  721.   v6 as STRING,        ;
  722.   v7 as STRING,        ;
  723.   v8 as STRING,        ;
  724.   v9 as STRING,        ;
  725.   v10 as STRING) ;
  726.      AS SHORTINT PASCAL: CAVORT10.924
  727.  
  728. _DLL INTERNAL _VOSPRINTF:CAVORT10.925
  729. _DLL INTERNAL _VOVSPRINTF:CAVORT10.926
  730.  
  731. FUNCTION VO_SPrintF(Format,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10)
  732.   local ptrBuff as PSZ
  733.   local sOutput as String
  734.   if IsNumeric(Format)
  735.     format := __CavoStr(format)
  736.   endif
  737.   Default(@V1, Null_String)
  738.   Default(@V2, Null_String)
  739.   Default(@V3, Null_String)
  740.   Default(@V4, Null_String)
  741.   Default(@V5, Null_String)
  742.   Default(@V6, Null_String)
  743.   Default(@V7, Null_String)
  744.   Default(@V8, Null_String)
  745.   Default(@V9, Null_String)
  746.   Default(@V10,Null_String)
  747.   if !Empty(format)
  748.       ptrBuff:=MemAlloc(256)
  749.       VOError10_SPrintF(ptrBuff,format,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10)
  750.       sOutput := Psz2String(psz(_cast,ptrBuff))
  751.       MemFree(ptrBuff)
  752.   endif
  753.   return sOutput
  754.  
  755. STATIC FUNCTION Write2(siFile AS SHORTINT, c AS _NC STRING) AS WORD PASCAL
  756.   LOCAL wRet AS WORD
  757.   wRet :=FPutS(siFile, c)
  758.   FCommit(siFile)
  759.   RETURN wRet
  760. STATIC FUNCTION Write3(siFile AS SHORTINT, c AS _NC STRING, wCount AS WORD) AS WORD PASCAL
  761.   LOCAL wRet AS WORD
  762.   wRet :=FPutS3(siFile, c, wCount)
  763.   FCommit(siFile)
  764.   RETURN wRet
  765.