Sign in to follow this  
Followers 0
willwatters

Error Messages

3 posts in this topic

I'm going to create a database with all my error messages: error number, description, etc.

In my code if an error happens I want the error to reference what is in the database (so I only have to change the contents of an error message once - on the database) and then write this to a database. For example, if error number 3 happens I want it to search the database for error number 3 and write this error to a different database of results for the test.

If autoit v3 is unable to read or write to a database then a file would do.

How do I do this please?

Share this post


Link to post
Share on other sites



U can use a txt file for logging error.

I use it for a script I wrote so I can see who uses it and what happen.

Maybe U can look at a piece if my script an go from there....

Dim $Versie = "3.2.1.1"   ; This could be your script version
Dim $Today = @MDAY & "-" & @MON & "-" & @YEAR
Dim $Time = @HOUR & ":" & @MIN & ":" & @SEC
Dim $Naam = "NAME"        ; Accually was - StringUpper(RegRead("HKEY_CURRENT_USER\SOFTWARE\CQR", "Naam"))
Dim $Plaats = "PLAATS"    ; Accually was - StringUpper(RegRead("HKEY_CURRENT_USER\SOFTWARE\CQR", "Plaats"))
Dim $Log = "C:\" & $Plaats & "-" & $Naam & ".txt"
Dim $ScreenChk
Dim $WriteChk = 0

$ScreenChk = "OVWR01"     ; Accually was - StringReplace(ClipGet(), " ","")

If $ScreenChk = "OVWR01" Then
   While $WriteChk = 0
      $file = FileOpen($Log , 1)
     ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "ALL_OK_!" & @TAB & $Versie & @CRLF)
   FileClose($file)
ElseIf $ScreenChk = "OVWI02R" Then
      While $WriteChk = 0
      $file = FileOpen($Log , 1)
     ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "OVWIO2R!" & @TAB & $Versie & @CRLF)
   FileClose($file)
   Exit
Else
   While $WriteChk = 0
      $file = FileOpen($Log , 1)
     ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "VKSCHRM!" & @TAB & $Versie & @CRLF)
   FileClose($file)
   Exit
EndIf

If you run the code it will create a txt file on the C:\ called "PLAATS-NAME.txt"

Experiment with this and build from here, then implement it in your own script. :idiot:

Hope this is usefull!!

Share this post


Link to post
Share on other sites

U can use a txt file for logging error.

I use it for a script I wrote so I can see who uses it and what happen.

Maybe U can look at a piece if my script an go from there....

Dim $Versie = "3.2.1.1"  ; This could be your script version
Dim $Today = @MDAY & "-" & @MON & "-" & @YEAR
Dim $Time = @HOUR & ":" & @MIN & ":" & @SEC
Dim $Naam = "NAME"        ; Accually was - StringUpper(RegRead("HKEY_CURRENT_USER\SOFTWARE\CQR", "Naam"))
Dim $Plaats = "PLAATS"    ; Accually was - StringUpper(RegRead("HKEY_CURRENT_USER\SOFTWARE\CQR", "Plaats"))
Dim $Log = "C:\" & $Plaats & "-" & $Naam & ".txt"
Dim $ScreenChk
Dim $WriteChk = 0

$ScreenChk = "OVWR01"    ; Accually was - StringReplace(ClipGet(), " ","")

If $ScreenChk = "OVWR01" Then
   While $WriteChk = 0
      $file = FileOpen($Log , 1)
    ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "ALL_OK_!" & @TAB & $Versie & @CRLF)
   FileClose($file)
ElseIf $ScreenChk = "OVWI02R" Then
      While $WriteChk = 0
      $file = FileOpen($Log , 1)
    ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "OVWIO2R!" & @TAB & $Versie & @CRLF)
   FileClose($file)
   Exit
Else
   While $WriteChk = 0
      $file = FileOpen($Log , 1)
    ; Check if file opened for writing OK
      If $file = -1 Then
          $WriteChk = 0
      Else
         $WriteChk = 1
      EndIf
   Wend
   FileWrite($file, $Today & @TAB & $Time & @TAB & $Naam & @TAB & $Plaats & @TAB & "VKSCHRM!" & @TAB & $Versie & @CRLF)
   FileClose($file)
   Exit
EndIf

If you run the code it will create a txt file on the C:\ called "PLAATS-NAME.txt"

Experiment with this and build from here, then implement it in your own script.  :idiot:

Hope this is usefull!!

<{POST_SNAPBACK}>

:D Hello DaLiMan thx for your nice code exampel wörks very nice for me)) :lol:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0