Jump to content

Search all .au3 files for new Beta functions


BigDaddyO
 Share

Recommended Posts

Hello All,

I have been using the Beta version of AutoIT v3 for quite some time, but most of the scripts that I use I have to constantly update. If I didn't have to make changes/updates and then re-compile with the new version I wouldn't really have any problems.

So, I wrote a little script that will search a folder and all sub folders for all .au3 files, and read through each line of the files looking for any of the functions that have changed in the new BETA version. It will then log which files have the BETA functions and what line the function is on.

edit: hmm, I just realized you can search all your .au3 files for anything, such as if you have an include file that you made and if you make a change to it you can use this to search for the inclusion file name and it will bring up every .au3 file that uses it.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1
; Author:        MikeOsdx
;
; Script Function:
;   Search through an entire directory and sub folders for all .au3 files
;   Search each .au3 file for the beta functions that have changed since the last release
;   build a file that lists the .au3 file, function noted, line it was on
;
; ----------------------------------------------------------------------------

HotKeySet("{ESC}", "Terminate")
Func Terminate()
  Exit
EndFunc ;==>Terminate

#Include <File.au3>
#Include <Array.au3>
$FileList = ""
$HomeFolder = FileSelectFolder("Folder to Search", "")
$Progress = ProgressOn("Processing AutoITv3 files", "Finding all .au3 files", "0 Percent")
$FolderList = _FileListToArray($HomeFolder, "*.*",2)
    $FirstSearch = FileFindFirstFile($HomeFolder & "\*.au3")
    While 1
        $File = FileFindNextFile($FirstSearch)
        if @error then ExitLoop
        $FileList = $FileList & $HomeFolder & "\" & $File & @CRLF
    WEnd    
    FileClose($FirstSearch)
if IsArray($FolderList) = 1 Then
    for $i = 1 to $FolderList[0]
        $Search = FileFindFirstFile($HomeFolder & "\" & $FolderList[$i] & "\*.au3")
        While 1
            $File = FileFindNextFile($Search)
            if @error then ExitLoop
            $FileList = $FileList & $HomeFolder & "\" & $FolderList[$i] & "\" & $File & @CRLF
        WEnd    
        FileClose($Search)
    Next
EndIf

; $FileList now holds all of the file names of the au3 files in the folder selected.
; Begin looking through each file for any of the functions that were listed as modified in the BETA release

$Affected = ""
Dim $Function
Dim $lineArray
_FileReadToArray("Functions.txt", $Function)
$Files = StringSplit($FileList, @CRLF)
For $i = 1 to $Files[0]
$Percent = Round($i / $Files[0] * 100, 0)
$FileOnly = StringSplit($Files[$i], "\")
    ProgressSet($percent, $percent & " % Complete", "Processing " & $FileOnly[$FileOnly[0]])
    if $Files[$i] = "" then ContinueLoop
    _FileReadToArray($Files[$i], $lineArray)
    if IsArray($lineArray) = 1 Then
        for $x = 1 to $lineArray[0]
            for $f = 1 to $Function[0]
                if StringInStr($lineArray[$x], $Function[$f]) > 0 Then
                    if StringInStr($Affected, $Files[$i]) Then
                        $Affected = $Affected & @TAB & "Line Number " & $x & " uses function " & $Function[$f] & @CRLF
                    Else
                        $Affected = $Affected & @CRLF & $Files[$i] & @CRLF & @TAB & "Line Number " & $x & " uses function " & $Function[$f] & @CRLF
                    EndIf
                EndIf
            Next
        Next
    EndIf
Next
ProgressOff( )
$LogFile = FileOpen($HomeFolder & "\Affected files.txt", 2)
FileWrite($LogFile, $Affected)
Run(@SystemDir & "\notepad.exe " & $HomeFolder & "\Affected files.txt")

You have to fill out a Functions.txt file that needs to be in the same folder as the script. one function per line.

Here is an example Functions.txt file.

Binary
IsBinary
@OSVersion
_FileListToArray

If you have any questions or suggestions let me know.

Mike

Edited by MikeOsdx
Link to comment
Share on other sites

but if it is a UDF called Binary it shouldnt be in the report IMO B)

I agree with you, But I can't think of any way to determine if it's a UDF or a built in Function. Besides if it's a UDF with the same name as a Built in function won't that cause problems?

Unless you are using Beta Functions created in your own UDF that are included in Non-Beta scripts, but then why not just update them to Full Beta Scripts?

Mike

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