home *** CD-ROM | disk | FTP | other *** search
/ Diccionario Visual Trilingue / VISUAL.iso / SHARED.DIR / 10089_Error.ls < prev    next >
Encoding:
Text File  |  1997-07-04  |  8.1 KB  |  180 lines

  1. on InitLogFile ErrToScreen
  2.   global gErrLogFileObj, gEditorLanguage, gPrefsPath
  3.   set gErrLogFileObj to FileIO(mnew, "READ", gPrefsPath & "Err.log")
  4.   if objectp(gErrLogFileObj) then
  5.     gErrLogFileObj(mdispose)
  6.     set gErrLogFileObj to FileIO(mnew, "APPEND", gPrefsPath & "Err.log")
  7.   else
  8.     set gErrLogFileObj to FileIO(mnew, "WRITE", gPrefsPath & "Err.log")
  9.     if objectp(gErrLogFileObj) then
  10.       gErrLogFileObj(mWriteString, "================================================================================" & RETURN)
  11.       gErrLogFileObj(mWriteString, " IVD Error's Log File" & RETURN & " Creation date :" && the long time & "   " & the date & RETURN)
  12.       gErrLogFileObj(mWriteString, "================================================================================" & RETURN & RETURN)
  13.     end if
  14.   end if
  15.   if not objectp(gErrLogFileObj) and ErrToScreen then
  16.     alert(getString(#ERRORLOGLINE1, gEditorLanguage) & gErrLogFileObj & getString(#ERRORLOGLINE2, gEditorLanguage) & RETURN)
  17.   end if
  18. end
  19.  
  20. on CloseError
  21. end
  22.  
  23. on checkError ErrNo, ErrType, ErrToScreen, LogString, fatalErr
  24.   global gErrLogFileObj, gNbErr, gLstError, gEditorLanguage
  25.   if (the paramCount < 3) or (the paramCount > 5) then
  26.     alert("CheckError : Erreur dans le nombre de parametres." & RETURN & RETURN & "Utilisation :" & RETURN & "CheckError(ErrNo,ErrType,ErrToScreen[,LogString])")
  27.     if objectp(gErrLogFileObj) then
  28.       gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN & "-- Erreur dans le nombre de parametres." & RETURN & "-- Utilisation :" && "CheckError(ErrNo,ErrType,ErrToScreen[,LogString])" & RETURN & RETURN)
  29.     end if
  30.     set ReturnCode to 1
  31.   else
  32.     if objectp(ErrNo) then
  33.       set ReturnCode to 0
  34.     else
  35.       if (ErrType = #RAM) or (ErrType = #AllocRAM) then
  36.         if ((ErrNo > the freeBytes) and (ErrType = #RAM)) or ((ErrNo > (the memorysize / 1024)) and (ErrType = #AllocRAM)) then
  37.           set ErrFound to ScanError(-1, ErrType)
  38.           if ErrToScreen then
  39.             alert(getString(#RAMERRORLINE1, gEditorLanguage) && getAt(gLstError, ErrFound + 2) & RETURN & RETURN & getString(#RAMERRORLINE2, gEditorLanguage) && Convert(ErrNo - the freeBytes) && getString(#RAMERRORLINE3, gEditorLanguage))
  40.           end if
  41.           if objectp(gErrLogFileObj) then
  42.             if (LogString <> EMPTY) and (the paramCount = 4) then
  43.               gErrLogFileObj(mWriteString, the long time & "   " & the date & "   [" & LogString & "]" & RETURN)
  44.             else
  45.               gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN)
  46.             end if
  47.             gErrLogFileObj(mWriteString, "--" && "Erreur RAM :" && getAt(gLstError, ErrFound + 2) & RETURN & "-- Vous avez besoin de" && Convert(ErrNo - the freeBytes) && "octets suppl├⌐mentaires." & RETURN & RETURN)
  48.           end if
  49.           set ReturnCode to 1
  50.         else
  51.           set ReturnCode to 0
  52.         end if
  53.       else
  54.         if ErrType = #QuickTime then
  55.           if not (the quickTimePresent) then
  56.             set ErrFound to ScanError(-1, ErrType)
  57.             if ErrToScreen then
  58.               alert(getAt(gLstError, ErrFound + 2) & RETURN)
  59.             end if
  60.             if objectp(gErrLogFileObj) then
  61.               if (LogString <> EMPTY) and (the paramCount = 4) then
  62.                 gErrLogFileObj(mWriteString, the long time & "   " & the date & "   [" & LogString & "]" & RETURN)
  63.               else
  64.                 gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN)
  65.               end if
  66.               gErrLogFileObj(mWriteString, "--" && getAt(gLstError, ErrFound + 2) & RETURN & RETURN)
  67.             end if
  68.             set ReturnCode to 1
  69.           else
  70.             set ReturnCode to 0
  71.           end if
  72.         else
  73.           if ErrType = #printer then
  74.             set ErrFound to ScanError(-1, ErrType)
  75.             if ErrToScreen then
  76.               alert(getAt(gLstError, ErrFound + 2) & RETURN)
  77.             end if
  78.             if objectp(gErrLogFileObj) then
  79.               if (LogString <> EMPTY) and (the paramCount = 4) then
  80.                 gErrLogFileObj(mWriteString, the long time & "   " & the date & "   [" & LogString & "]" & RETURN)
  81.               else
  82.                 gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN)
  83.               end if
  84.               gErrLogFileObj(mWriteString, "--" && getAt(gLstError, ErrFound + 2) & RETURN & RETURN)
  85.             end if
  86.             set ReturnCode to 1
  87.           else
  88.             if ErrType = #DataBase then
  89.               set ErrFound to ScanError(ErrNo, ErrType)
  90.               if (ErrFound <> 0) and (getAt(gLstError, ErrFound + 2) <> EMPTY) then
  91.                 if ErrToScreen then
  92.                   alert(getAt(gLstError, ErrFound + 2) & RETURN)
  93.                 end if
  94.                 if objectp(gErrLogFileObj) then
  95.                   if (LogString <> EMPTY) and (the paramCount = 4) then
  96.                     gErrLogFileObj(mWriteString, the long time & "   " & the date & "   [" & LogString & "]" & RETURN)
  97.                   else
  98.                     gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN)
  99.                   end if
  100.                   gErrLogFileObj(mWriteString, "--" && line 1 of getAt(gLstError, ErrFound + 2) & RETURN & RETURN)
  101.                 end if
  102.                 set ReturnCode to 1
  103.               else
  104.                 set ReturnCode to 0
  105.               end if
  106.             else
  107.               set ErrFound to ScanError(ErrNo, ErrType)
  108.               if ErrFound <> 0 then
  109.                 if getAt(gLstError, ErrFound + 2) = EMPTY then
  110.                   set ReturnCode to 0
  111.                 else
  112.                   if ErrToScreen then
  113.                     alert(getString(#ERROR, gEditorLanguage) && getAt(gLstError, ErrFound) && ": (" & getAt(gLstError, ErrFound + 1) & ")" && getAt(gLstError, ErrFound + 2))
  114.                   end if
  115.                   if objectp(gErrLogFileObj) then
  116.                     if (LogString <> EMPTY) and (the paramCount = 4) then
  117.                       gErrLogFileObj(mWriteString, the long time & "   " & the date & "   [" & LogString & "]" & RETURN)
  118.                     else
  119.                       gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN)
  120.                     end if
  121.                     gErrLogFileObj(mWriteString, "--" && "Erreur" && getAt(gLstError, ErrFound) && ": (" & getAt(gLstError, ErrFound + 1) & ")" && getAt(gLstError, ErrFound + 2) & RETURN & RETURN)
  122.                   end if
  123.                   set ReturnCode to 1
  124.                 end if
  125.               else
  126.                 if ErrToScreen then
  127.                   alert(string(ErrType) && getString(#ERRORUNKNOWN, gEditorLanguage))
  128.                 end if
  129.                 if objectp(gErrLogFileObj) then
  130.                   gErrLogFileObj(mWriteString, the long time & "   " & the date & RETURN & "--" && string(ErrType) && ": Erreur inconnue..." & RETURN & "-- Parametres recus par CheckError:" && ErrNo && "," && ErrType & "," && ErrToScreen)
  131.                   if the paramCount = 4 then
  132.                     gErrLogFileObj(mWriteString, "," && numToChar(34) & LogString & numToChar(34) & "." & RETURN & RETURN)
  133.                   else
  134.                     gErrLogFileObj(mWriteString, "." & RETURN & RETURN)
  135.                   end if
  136.                 end if
  137.                 set ReturnCode to 1
  138.               end if
  139.             end if
  140.           end if
  141.         end if
  142.       end if
  143.     end if
  144.   end if
  145.   if (ReturnCode = 1) and fatalErr then
  146.     quit()
  147.   else
  148.     return ReturnCode
  149.   end if
  150. end
  151.  
  152. on ScanError ENo, EType
  153.   global gNbErr, gLstError
  154.   set EFound to 0
  155.   repeat with i = 1 to gNbErr
  156.     if (getAt(gLstError, ((i - 1) * 3) + 1) = EType) and (getAt(gLstError, ((i - 1) * 3) + 2) = ENo) then
  157.       set EFound to ((i - 1) * 3) + 1
  158.       set i to gNbErr + 1
  159.     end if
  160.   end repeat
  161.   return EFound
  162. end
  163.  
  164. on Convert Num
  165.   set Res to EMPTY
  166.   set TheNum to string(Num)
  167.   if offset(".", TheNum) <> 0 then
  168.     set TheNum to chars(TheNum, 1, offset(".", TheNum) - 1)
  169.   end if
  170.   set len to length(TheNum)
  171.   repeat with i = len down to 1
  172.     if ((i mod 3) = 0) and (i <> len) then
  173.       set Res to Res & ","
  174.     end if
  175.     set Res to Res & chars(TheNum, 1, 1)
  176.     set TheNum to chars(TheNum, 2, length(TheNum))
  177.   end repeat
  178.   return Res
  179. end
  180.