Jump to content

Regular Expression Help


CygnusX1
 Share

Recommended Posts

  • Moderators
I think where you might be confused is when assigning a variable a function name from within your script.
eg.
Global $ghCWrite = ConsoleWrite
$ghCWrite("This is a test" & @CRLF)
That assigns a pointer or object reference to the variable $ghCWrite for the function ConsoleWrite.
 
Retrieving strings from a file (or any string for that matter) is not setting a pointer/object to the variable, it's setting a string.
 
To assign it, you could probably get away with (run this in a separate test file):
 
Global $gszFRead = FileRead(@ScriptFullPath)
Global $gaFuncs = StringRegExp($gszFRead, "(?i)(?:^|\v)[\s\w]*func\s*(\w+)\s*\(", 3)
Global $ghMyFunc = TestCaseOne
ConsoleWrite(VarGetType($ghMyFunc) & @CRLF)
 
For $iFunc = 0 To UBound($gaFuncs) - 1
    $ghMyFunc = Execute($gaFuncs[$iFunc]) ; assign the pointer/object to $ghMyFunc
    ConsoleWrite(VarGetType($ghMyFunc) & @CRLF)
    $ghMyFunc() ; call the func
Next
 
Func TestCaseOne()
    MsgBox(0, 0, "Case One")
EndFunc
 
Func TestCaseTwo()
    MsgBox(0, 0, "Case Two")
EndFunc
 
Otherwise, use the Call() method I've discussed above.
Edited by SmOke_N
fixed parenthesis calling func

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

@SmOke_N

'(?im)(?:^|.*s)Funcs*(w+)'   gets the volatile funcs  :)

Yes, but it also gets commented out lines or string quotes from continuation lines as well ;) .. I use similar methods when writing obfuscators.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...