Jump to content

Recommended Posts

Posted

Hello,

I am aware that there have been some discussions (e.g. https://www.autoitscript.com/trac/autoit/ticket/3864) around this issue.

I ran into while testing several regular expression and while I could narrow it down easily, I was wondering if it possible to get the an error handler to "catch" that error, but I guess not, or?
 

Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc")

; This is a custom error handler
Func ErrFunc($oError)
    Local $bHexNumber = Hex($oError.number, 8)
    ConsoleWrite(@CRLF & @CRLF & "We intercepted a COM Error ! " & _
            " Number: 0x " & Hex($oError.number, 8) & @CRLF & _
            "Description: " & $oError.windescription & _
            "At line: " & $oError.scriptline & @CRLF & @CRLF & _
            "@AutoItVersion = " & @AutoItVersion & @CRLF & _
            "@AutoItX64 = " & @AutoItX64 & @CRLF & _
            "@Compiled = " & @Compiled & @CRLF & _
            "@OSArch = " & @OSArch & @CRLF & _
            "@OSVersion = " & @OSVersion & @CRLF & _
            "Scriptline = " & $oError.scriptline & @CRLF & _
            "NumberHex = " & $bHexNumber & @CRLF & _
            "Number = " & $oError.number & @CRLF & _
            "WinDescription = " & StringStripWS($oError.WinDescription, 2) & @CRLF & _
            "Description = " & StringStripWS($oError.Description, 2) & @CRLF & _
            "Source = " & $oError.Source & @CRLF & _
            "HelpFile = " & $oError.HelpFile & @CRLF & _
            "HelpContext = " & $oError.HelpContext & @CRLF & _
            "LastDllError = " & $oError.LastDllError & @CRLF)
EndFunc   ;==>ErrFunc

_Example()

Func _Example()
    Local Const $s_RegExp = _     ; $s_RegExp comes from Func _PathSplit(
            '^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$'

    Local $sString = 'xxxxxxxxxx'
    For $iCounter = 1 To 11
        ConsoleWrite("- step #" & $iCounter & ' StringLen= ' & StringLen($sString) & @CRLF)
        StringRegExp($sString, $s_RegExp, 0)
        $sString &= $sString
    Next
EndFunc   ;==>_Example

 

Posted

You can use my multi-threading UDF this way:

#AutoIt3Wrapper_UseX64=y

#include "PMT-UDF.AU3"
#include <Constants.au3>

_PMT_Init()

Local $hProc1 = _PMT_Start("_Example")

Local $sResponse
While Sleep(50)
  $sResponse = _PMT_GetResponse($hProc1)
  If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped")
  If $sResponse <> "" Then
    MsgBox($MB_OK + $MB_TOPMOST, "Success", $sResponse & @CRLF)
    ExitLoop
  EndIf
WEnd

Func _Example()
  Local Const $s_RegExp = _       ; $s_RegExp comes from Func _PathSplit(
      '^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$'

  Local $sString = 'xxxxxxxxxx'
  For $iCounter = 1 To 11
    StringRegExp($sString, $s_RegExp, 0)
    $sString &= $sString
  Next
  Return "OK"
EndFunc   ;==>_Example

 

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
×
×
  • Create New...