Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/07/2022 in Posts

  1. It seems my translation from C# to Autoit does the same calculation. I need the LRC as a checksum to determine if the RS232 communication to and from our pay terminal data was without errors. Both the C# and Autoit calculate the same LRC value of: 0x05 Also with other data the LRC in both scripts have the same results. IN THE ABOVE CASE, The pay terminal generatest LRC of: 0x06 (instead of 0x05) Almost all my LRCs are 1,2 or 3 digits off. Mostly only 1. I have to ivestigate further 😉
    1 point
  2. Nine

    Format Text or Mask Display.

    Here : $InstallDate = "20201123104757.000000-180" $TotalMemory = 8201288 MsgBox(0,"", StringRegExpReplace($InstallDate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2}).*", "$1/$2/$3 $4:$5")) MsgBox(0,"", GetNum($TotalMemory)) Func GetNum($iNum) Local $aSig = ["K", "M", "G", "T"] For $i = 0 to UBound($aSig) - 2 If $iNum < 1000 Then Return $iNum & $aSig[$i] $iNum = Floor($iNum/1000) Next Return $iNum & $aSig[$i] EndFunc When you post code, use the method shown in the link
    1 point
  3. I once had this problem in an earlier version of AutoIt, The problem was caused by the $oError not being an Objetc. If this situation Appears it cause Object failed when accessing $oError.scriptline ou any other propriety of $oError ant the Srcript is terminated The solution was to determine whether $oErro is an Object before mounting the error se the example below ; INTERCEPTOR Of COMError for IE =========================================== Local $R = _IEErrorHandlerRegister("_ErrFunc") If $R <> 1 Or @error Then MsgBox(0x40010,Default,'ERROR Executing: $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")') Global $sCOMErr ; String with last Error Global $oCOMError ; Objeto with last Error Global $Trace = True ; Set to display the Error in the Console ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) If Not IsObj($oError) Then ; This is nessesary to prevento the program crashing ConsoleWrite("! ===================== _ErrFunc($oError) $oError Is Not Objeto ==========================================" & @LF) Return EndIf $oCOMError = $oError ; Armazena uma Copia dos Erros $sCOMErr = @ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF If $Trace Then ConsoleWrite(@CRLF & @CRLF & "! ================= Object ERROR ==========================================================" & @CRLF & @CRLF & _ ">" & StringReplace(StringReplace($sCOMErr,@CRLF & @CRLF,@CRLF,0,1),@CRLF,@CRLF & ">",0,1) & @CRLF & _ "! =========================================================================================" & @CRLF & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>_ErrFunc Another solution if you are using the AutoIt version 3.3.14.2 is to adjust the #Include <IE.au3> Func below added to row If Not IsObj ($ oCOMError) Then Return; IT can be invaluable because it can happen to $ oCOMError not be an object The doubt here is if indeed there was a COMError or not there was to have put q Return SetError ($_ IEStatus_ComError) rather than only Return if not Object ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __IEInternalErrorHandler ; Description ...: to be called on error ; Author ........: Dale Hohm ; Modified ......: ; =============================================================================================================================== Func __IEInternalErrorHandler($oCOMError) If Not IsObj($oCOMError) Then Return ; ISSO É Nesessario pois pode acontecer de $oCOMError não ser um Objeto If $__g_bIEErrorNotify Or $__g_bIEAU3Debug Then ConsoleWrite("--> " & __COMErrorFormating($oCOMError, "----> $IEComError") & @CRLF) SetError($_IEStatus_ComError) Return EndFunc ;==>__IEInternalErrorHandle
    1 point
×
×
  • Create New...