Jump to content

Recommended Posts

Posted

Hi ppl, im trying to do a script that reads an .au3 file, and retrieves all variables in it, then i work with that.

This is what i got so far

#include <Array.au3>
$File = FileOpenDialog('Au3 Var Searcher', @ScriptDir, 'Au3Files (*.au3)')
$FileOpen = FileOpen($File)
$FileRead = FileRead($FileOpen)
FileClose($FileOpen)
Search()
Func Search()
Local $aArray = StringRegExp($FileRead, '$[:alnum:][:blank:]', 2)
ConsoleWrite(' - '& $aArray[0] &' - '&@MSEC&@CRLF)
_ArrayDisplay($aArray)
EndFunc

 

So we know it has to start with $, and have [:alnum:] until [:blank:] or simply not [:alnum:] anymore. Or is there another way?

Thanks in advance
 

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

You might want to look through Guinness's sig.  He has done a mountain of au3 parsing work.

edit: as a quick and dirty you might try this pattern...

Local $aArray = StringRegExp($FileRead, '(\$\w+)', 3)

 

Edited by kylomas
additional info

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

 

This will return an array of all the variable names starting with $

#include <Array.au3>
$File = FileOpenDialog('Au3 Var Searcher', @ScriptDir, 'Au3Files (*.au3)')
$FileOpen = FileOpen($File)
$FileRead = FileRead($FileOpen)
FileClose($FileOpen)
Search()
Func Search()
Local $aArray = StringRegExp($FileRead, '(\$[A-Za-z0-9_]+)[^A-Za-z0-9_]', 3)
ConsoleWrite(' - '& $aArray[0] &' - '&@MSEC&@CRLF)
_ArrayDisplay($aArray)
EndFunc

 

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Posted

Thanks a bunch, both solutions work perfect, and i was "decyphering" and it seems i was not far in terms of thinking.

I'll leave yet another pattern, now that i understood how it works :P

(\$[[:alnum:]_]+)[^[:alnum:]_]

Thanks a lot both!

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
  On 1/30/2016 at 10:06 PM, kylomas said:

You might want to look through Guinness's sig.

Expand  

I agree.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Yeah, it seems you already done it with "List all unique variables in a script".

Nice.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

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...