Jump to content

Parse all includes in a script file.


guinness
 Share

Recommended Posts

@Jos

Thanks, very useful

@guinness

the complete code and this fate so just for fun

#include <file.au3>
#include <Array.au3>

;Global $sIncludeDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt", "InstallDir") & "\Include\"
Global $sIncludeDir = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 1, -1)) & "Include\"
;;Global $aInclude[2][4] = [[1,1,@LF,1]]

Global $aVarList, $sVarList = @LF, $aVariable, $aVarName, $aFuncName, $taFuncList, $aFuncList[1][3], $daFuncList
Global $ddd, $DXIE = 1, $sFileData, $aInclude, $taInclude, $sFilePath = FileOpenDialog("file*.au3", "", "AU3 (*.au3)", 1 + 4 )

If @error Then
    MsgBox(4096,"","No File(s) chosen")
Else
    $sFileData = _GetIncludeEx($sFilePath, 127)
    $aVariable = StringRegExp($sFileData, '(?is)\n\h*(?:Dim Const|Global Const|Local Const|Dim|Global|Local|Const)\h+([^\r\n]+)', 3)
    For $i = 0 To UBound($aVariable) - 1
        $aVarName = StringRegExp($aVariable[$i], '\h*(\$\w+)(?:[^\$"' & "'" & ']|"[^"]*"|' & "'[^']*'" & ')*', 3)
        ;;$aVarName = StringRegExp($aVariable[$i], '\h*(\$[^\$\r\n\h\,\=\&\.\(\)\[\]\;]+)(?:\[[^\]]*\])*(?:\h*\=\h*(?:[^\$"' & "'" & ']|"[^"]*"|' & "'[^']*'" & ')*)*', 3)
        For $y = 0 To UBound($aVarName) - 1
            If StringInStr($sVarList, @LF & $aVarName[$y] & @LF, 2) Or $aVarName[$y] = "$CmdLine" Or $aVarName[$y] = "$CmdLineRaw" Then ContinueLoop
            $sVarList &= $aVarName[$y] & @LF
        Next
    Next
    $aVariable = StringRegExp($sFileData, '(?i)\n\h*Func\h*[^\(]+\(([^\r\n\)]+)', 3)
    For $i = 0 To UBound($aVariable) - 1
        $aVarName = StringRegExp(',' & $aVariable[$i], '(?is),(?:ByRef)?\h*(\$\w+)', 3)    ;, '(?is),(?:ByRef)?\h*(\$[^\$\r\n\h\,\=\&\.\(\)\[\]\;]+)', 3)
        For $y = 0 To UBound($aVarName) - 1
            If StringInStr($sVarList, @LF & $aVarName[$y] & @LF, 2) Or $aVarName[$y] = "$CmdLine" Or $aVarName[$y] = "$CmdLineRaw" Then ContinueLoop
            $sVarList &= $aVarName[$y] & @LF
        Next
    Next
    $aVarList = StringSplit(StringTrimLeft(StringTrimRight($sVarList, 1), 1), @LF)
    $aVarName = _GetVariableName($aVarList[0])
    For $i = 1 To $aVarList[0]
        $sFileData = StringRegExpReplace($sFileData, '(?i)(?<!\w|\$)\Q' & $aVarList[$i] & '\E(?!\w|\$)', '\$' & $aVarName[$i])
        $ddd &= $aVarList[$i] & "|" & $aVarName[$i] & "|"
    Next
    $sFileData = StringRegExpReplace(StringRegExpReplace($sFileData, '[\r\n]\s*', @LF), '(?is)\n\h*EndFunc(?:[\h;][^\n]*\n|\n)', @LF & "EndFunc" & @CRLF)
    $taFuncList = StringRegExp($sFileData, '(?is)\n\h*Func\h+([^\r]*)\r', 3)
    If Not @Error Then
        $daFuncList = UBound($taFuncList) - 1
        ReDim $aFuncList[$daFuncList + 1][3]
        $ddd &= @CRLF & ";"
        $aFuncName = _GetVariableName($daFuncList + 1, 20, 1, 2)
        For $i = 0 To $daFuncList
            $aFuncList[$i][0] = $aFuncName[$i]
            $aFuncList[$i][1] = StringLeft($taFuncList[$i], StringInStr($taFuncList[$i], "(", 1) - 1)
            $aFuncList[$i][2] = @LF & "Func " & $taFuncList[$i]
            $ddd &= $aFuncList[$i][1] & "|" & $aFuncName[$i] & "|"
        Next
        _ArraySort($aFuncList, 1)
        $sFileData = StringRegExpReplace($sFileData, '(?is)\n\h*Func\h+([^\r]*)', "")
        For $i = 0 To $daFuncList
            $sFileData &= $aFuncList[$i][2] & @LF
        Next
        For $i = 0 To $daFuncList
             $sFileData = StringRegExpReplace($sFileData, '(?i)(?<!\w)\Q' & $aFuncList[$i][1] & '\E(?!\w)', $aFuncList[$i][0])
            ;; or
            ;;$sFileData = StringRegExpReplace($sFileData, '(?i)(?<!\w)\Q' & $aFuncList[$i][1] & '(\E', $aFuncList[$i][0] & "\(")
            ;;$sFileData = StringRegExpReplace($sFileData, '(?i)(\sAdlibRegister\h*\(\h*["' & '"]*)(\Q' & $aFuncList[$i][1] & '\E)(["' & '"]*\h*\))', "$1" & $aFuncList[$i][0] & "$3")
            ;;$sFileData = StringRegExpReplace($sFileData, '(?i)(\sAdlibUnRegister\h*\(\h*["' & '"]*)(\Q' & $aFuncList[$i][1] & '\E)(["' & '"]*\h*\))', "$1" & $aFuncList[$i][0] & "$3")
            ;;$sFileData = StringRegExpReplace($sFileData, '(?i)(\sCall\h*\(\h*["' & '"]*)(\Q' & $aFuncList[$i][1] & '\E)(["' & '"]*\h*\))', "$1" & $aFuncList[$i][0] & "$3")
            ;;$sFileData = StringRegExpReplace($sFileData, '(?i)(\sDllCallbackRegister\h*\(\h*["' & '"]*)(\Q' & $aFuncList[$i][1] & '\E)(["' & '"]*\h*,)', "$1" & $aFuncList[$i][0] & "$3")
       Next
    Else
        $sFileData = StringRegExpReplace($sFileData, '(?is)\n\h*Func\h+([^\r]*)\r', "")
    EndIf
    $sFileData = ";" & $ddd & @CRLF & StringRegExpReplace($sFileData, '[\r\n]\s*', @CRLF)
    FileDelete(StringRegExpReplace($sFilePath & " ", "(\h\(\d+\))?(\.[^\.\\]*)?(\h)$", "_Encrypted$2"))
    FileWrite(StringRegExpReplace($sFilePath & " ", "(\h\(\d+\))?(\.[^\.\\]*)?(\h)$", "_Encrypted$2"), $sFileData)
EndIf

; #FUNCTION# ====================================================================================================================
; Name...........: _GetIncludeEx
; Description ...: Gell all Include
; Syntax.........: _GetIncludeEx($sFilePath[, $iFlags = 1])
; Parameters ....: $sFilePath        - Path and filename of the file to be read.
;               $iFlags            - Optional: (add the flags together for multiple operations):
;               |$iFlags = 1 Remove Comment (#cs or #comment-start & #ce or #comment-end)
;               |$iFlags = 2 Remove Comment (;comment ect ect)
;               |$iFlags = 4 strip all leading white space
;               |$iFlags = 8 strip all trailing white space
;               |$iFlags = 16 Remove Line empty
;               |$iFlags = 32 Remove Line empty or contain only whitespace character
;               |$iFlags = 64 Remove #Region or #EndRegion Lines
;               |$iFlags = 128 Return 2D Array List
; Return values .: String Data or 2D Array List
; Author ........: DXRW4E
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GetIncludeEx($sFilePath, $iFlags = 127)
    If $iFlags Then Global $aInclude[1955][4] = [[1,1,@LF,1953],[$sFilePath,"",StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 1, -1)) & "Include\"]]
    $aInclude[$aInclude[0][0]][1] = @CRLF & StringRegExpReplace(FileRead($sFilePath), '\r(?!\n)', @CRLF)
    Local $acInclude = StringRegExp($aInclude[$aInclude[0][0]][1], '(?is)\n\h*#include\h*[<"' & "']+\h*([^'<>" & '"]+)', 3)
    If Not @Error Then
        For $i = 0 To UBound($acInclude) - 1
            If StringInStr($aInclude[0][2], @LF & $acInclude[$i] & @LF, 2) Then ContinueLoop
            $aInclude[0][2] &= $acInclude[$i] & @LF
            If $aInclude[0][0] = $aInclude[0][3] Then
                If $aInclude[0][3] = 3999744 Then ExitLoop
                $aInclude[0][3] *= 2
                ReDim $aInclude[$aInclude[0][3] + 2][2]
            EndIf
            $aInclude[0][0] += 1
            $aInclude[$aInclude[0][0]][0] = $aInclude[1][2] & $acInclude[$i]
            If Not FileExists($aInclude[$aInclude[0][0]][0]) Then $aInclude[$aInclude[0][0]][0] = StringRegExpReplace($sFilePath, "(.*[\\/]).*", "$1") & $acInclude[$i]
            _GetIncludeEx($aInclude[$aInclude[0][0]][0], 0)
        Next
    EndIf
    If Not $iFlags Then Return
    If BitAND($iFlags, 128) = 128 Then
        ReDim $aInclude[$aInclude[0][0] + 1][2]
        $acInclude = $aInclude
    Else
        $aInclude[0][1] = $aInclude[1][1]
        $aInclude[1][0] = StringReplace($aInclude[0][2], @LF, @CRLF & ";")
        $aInclude[1][1] = @CRLF
        For $i = 2 To $aInclude[0][0]
            If StringRight($aInclude[$i][0], 13) = "Constants.au3" Then
                $aInclude[1][0] &= $aInclude[$i][1] & @CRLF
            Else
                $aInclude[1][1] &= $aInclude[$i][1] & @CRLF
            EndIf
        Next
        $acInclude = StringRegExpReplace($aInclude[1][0] & $aInclude[1][1] & $aInclude[0][1], '(?is)\n\h*#include\h*[^\n]*', "")
        If BitAND($iFlags, 1) = 1 Then $acInclude = StringRegExpReplace($acInclude, "(?is)(\n\h*#(?:cs|comments?-start)[^\n]*\n.*?\n\h*#(?:ce|comments?-end)[^\n]*)", @LF)
        If BitAND($iFlags, 2) = 2 Then $acInclude = StringRegExpReplace($acInclude, "\n\h*;[^\n]*", "")
        If BitAND($iFlags, 4) = 4 Then $acInclude = StringRegExpReplace($acInclude, "\n\h+", @LF)
        If BitAND($iFlags, 8) = 8 Then $acInclude = StringRegExpReplace($acInclude, "\h+(?=[\r\n])", "")
        If BitAND($iFlags, 16) = 16 Then $acInclude = StringRegExpReplace($acInclude, "\n[\r\n]*\n", @LF)
        If BitAND($iFlags, 32) = 32 Then $acInclude = StringRegExpReplace($acInclude, "\n\s*\n", @LF)
        If BitAND($iFlags, 64) = 64 Then $acInclude = StringRegExpReplace($acInclude, "(?i)\n\h*(?:#Region|#EndRegion)(?!\w)[^\n]*\n", @LF)
    EndIf
    $aInclude = ""
    Return $acInclude
EndFunc

Func _GetVariableName($ivName, $islvName = 20, $iFlags = 0, $iArray = 0)
    Local $svName, $avName[3]
    If $islvName < 2 Then $islvName = 2
    If $iFlags Then $islvName -= 1
    For $y = 1 To $ivName
        If $iFlags Then $svName &= Chr(Random(65, 90, 1))
        For $i = 1 To $islvName
            $avName[0] = Chr(Random(65, 90, 1)) ;A-Z
            $avName[1] = Chr(Random(97, 122, 1)) ;a-z
            $avName[2] = Chr(Random(48, 57, 1)) ;0-9
            $svName &= $avName[Random(0, 2, 1)]
        Next
        $svName &= @LF
    Next
    Return StringSplit(StringTrimRight($svName, 1), @LF, $iArray)
EndFunc
Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

Wow, impressive, alot to be learnt from that script. You've probably fixed this, but your code renames the functions but not when the functions are being called.

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

No I know how to fix, just was pointing out the issue.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

That Global should be Local and Static or could be ByRef, but not Global. I like your idea of eliminating the use of PathFindOnPath so I will adopt this approach from now on. Expect your name to appear in the SciTE Jump credits.

Edit: I'm dumb, you can't use Static with arrays that need re-dimming. Use Static again not ReDim.

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Thank you again, me too do not really like the Gobal then (I made an exception in this case), autoit altogether 130 includes, so do not think it ever will pass the array[1000] I mean everything else and only a precaution, however, as soon as I can, I'll try to review all the source code

Static is perfect in this case, but not used because it is experimental maybe he can get out of trouble after

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

Another issue which mine tackles is relative paths that are used. Take for example the ZIP file below as an example of perhaps not a typical include structure, but still valid.

guinness:

[0]|9

[1]|C:UsersguinnessDesktopExample.au3

[2]|C:Program FilesAutoIt3IncludeConstants.au3

[3]|C:Program FilesAutoIt3IncludeProcessConstants.au3

[4]|C:Program FilesAutoIt3IncludeFileConstants.au3

[5]|C:Program FilesAutoIt3IncludeDirConstants.au3

[6]|C:Program FilesAutoIt3IncludeColorConstants.au3

[7]|C:UsersguinnessDesktopExample_2.au3

[8]|C:UsersguinnessDesktopExampleFolderExample_3.au3

[9]|C:UsersguinnessDesktopExample_4.au3

DXRW4E:

[0]|9

[1]|C:UsersguinnessDesktopExample.au3

[2]|C:Program FilesAutoIt3IncludeConstants.au3

[3]|C:Program FilesAutoIt3IncludeProcessConstants.au3

[4]|C:Program FilesAutoIt3IncludeFileConstants.au3

[5]|C:Program FilesAutoIt3IncludeDirConstants.au3

[6]|C:Program FilesAutoIt3IncludeColorConstants.au3

[7]|C:UsersguinnessDesktopExample_2.au3

[8]|C:UsersguinnessDesktopExampleFolderExample_3.au3

[9]|C:UsersguinnessDesktopExampleFolder..Example_4.au3

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

You're right you know. Just placed an include in Example_4 pointing to Example_5 and it picked it up, ah because FileRead accepts relative paths. So it is just a cosmetic thing.

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I had to create this DXRW4E. I used Enum in the function for removing the use of magic numbers and readability too.

#include <Constants.au3>

Local $sData = FileRead(@ScriptFullPath)
_SourceCleanup($sData)
MsgBox($MB_SYSTEMMODAL, '', $sData)

; $iFlags = 1 Remove multi-comments (#cs or #comment-start & #ce or #comment-end)
; $iFlags = 2 Remove single-line comments (; Comment ... )
; $iFlags = 4 Strip all leading white space;
; $iFlags = 8 Strip all trailing white space.
; $iFlags = 16 Remove lines containing only @LF, @CR or @CRLF.
; $iFlags = 32 Remove lines containing only @LF, @CR, @CRLF or whitespace characters.
; $iFlags = 64 Remove #region or #endregion directives.
Func _SourceCleanup(ByRef $sData, $iFlags = Default) ; Regular expressions by DXRW4E & function layout by guinness.
    Local Enum Step *2 $eCLEANUP_MULTICOMMENTS, $eCLEANUP_SINGLECOMMENTS, $eCLEANUP_LEADINGWS, $eCLEANUP_TRAILINGWS, $eCLEANUP_EMPTYLINESONLY, _
            $eCLEANUP_STRIPEMPTYLINESPLUSWS, $eCLEANUP_REGIONS
    If $iFlags = Default Then
        $iFlags = BitOR($eCLEANUP_MULTICOMMENTS, $eCLEANUP_SINGLECOMMENTS, $eCLEANUP_LEADINGWS, $eCLEANUP_TRAILINGWS, $eCLEANUP_EMPTYLINESONLY, _
                $eCLEANUP_STRIPEMPTYLINESPLUSWS, $eCLEANUP_REGIONS)
    EndIf
    If BitAND($iFlags, $eCLEANUP_MULTICOMMENTS) = $eCLEANUP_MULTICOMMENTS Then
        $sData = StringRegExpReplace($sData, '(?is)(\n\h*#(?:cs|comments?-start)[^\n]*\n.*?\n\h*#(?:ce|comments?-end)[^\n]*)', @LF)
    EndIf
    If BitAND($iFlags, $eCLEANUP_SINGLECOMMENTS) = $eCLEANUP_SINGLECOMMENTS Then
        $sData = StringRegExpReplace($sData, '\n\h*;[^\n]*', '')
    EndIf
    If BitAND($iFlags, $eCLEANUP_LEADINGWS) = $eCLEANUP_LEADINGWS Then
        $sData = StringRegExpReplace($sData, '\n\h+', @LF)
    EndIf
    If BitAND($iFlags, $eCLEANUP_TRAILINGWS) = $eCLEANUP_TRAILINGWS Then
        $sData = StringRegExpReplace($sData, '\h+(?=[\r\n])', '')
    EndIf
    If BitAND($iFlags, $eCLEANUP_EMPTYLINESONLY) = $eCLEANUP_EMPTYLINESONLY Then
        $sData = StringRegExpReplace($sData, '\n[\r\n]*\n', @LF)
    EndIf
    If BitAND($iFlags, $eCLEANUP_STRIPEMPTYLINESPLUSWS) = $eCLEANUP_STRIPEMPTYLINESPLUSWS Then
        $sData = StringRegExpReplace($sData, '\n\s*\n', @LF)
    EndIf
    If BitAND($iFlags, $eCLEANUP_REGIONS) = $eCLEANUP_REGIONS Then
        $sData = StringRegExpReplace($sData, '(?i)\n\h*(?:#Region|#EndRegion)(?!\w)[^\n]*\n', @LF)
    EndIf
EndFunc   ;==>_SourceCleanup

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

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