jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 (edited) Edit: See this thread for the updated version: >Baroque AutoIt3 Parser I hope this fits in here. I hate to work on someone's script when it doesn't have spaces after commas, before and after equality operators, before and after semicolons etc. So I made a very simple numbskull script to format those situations. Edit: I'm so excited! I've wanted to be able to write parsing code for so long! This is my best attempt yet! WOOT! expandcollapse popup#include-once Global Const $line_feed = @LF Global Const $space = ' ' #region ; autoit_format Func autoit_format(Const $au3_path) If Not IsString($au3_path) Then Return SetError(1, 0, False) Local Const $raw_au3 = FileRead($au3_path) If @error Then Return SetError(2, 0, False) Local Const $au3 = strip_whitespace($raw_au3) Local Const $au3_length = StringLen($au3) #region ; Tokens Local Const $hash = '#' Local Const $double_quote = Chr(34) Local Const $single_quote = Chr(39) Local Const $comma = ',' Local Const $semicolon = ';' Local Const $equal = '=' Local Const $ampersand = '&' Local Const $plus = '+' Local Const $minus = '-' Local Const $asterisk = '*' Local Const $forward_slash = '/' Local Const $open_bracket = '[' Local Const $close_bracket = ']' Local Const $open_parens = '(' Local Const $close_parens = ')' Local Const $open_angle_bracket = '<' Local Const $close_angle_bracket = '>' #endregion ; Tokens Local $within_string = False Local $formatted_au3 = '' Local $token = '' Local $previous_token = '' Local $next_token = '' For $i = 1 To $au3_length $token = StringMid($au3, $i, 1) $previous_token = StringMid($au3, $i - 1, 1) $next_token = StringMid($au3, $i + 1, 1) Switch $token Case $double_quote, $single_quote Switch $within_string Case True $within_string = False Case False $within_string = True EndSwitch EndSwitch Switch Not $within_string Case True Switch $token Case $space Select Case $next_token = $comma ContinueLoop EndSelect Case $comma Select Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $next_token <> $space $token = $token & $space EndSelect Case $equal Switch $next_token = $equal Case True Select Case $previous_token <> $space And StringMid($au3, $i + 2, 1) <> $space $token = $space & $equal & $equal & $space $i += 1 Case $previous_token = $space And StringMid($au3, $i + 2, 1) <> $space $token = $equal & $equal & $space $i += 1 Case $previous_token <> $space And StringMid($au3, $i + 2, 1) = $space $token = $space & $equal & $equal $i += 1 EndSelect Case False Select Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token Case $previous_token = $space And $next_token <> $space $token = $token & $space EndSelect EndSwitch Case $semicolon Select Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space Case $previous_token <> $space And _ $previous_token <> $line_feed And _ $next_token <> $space $token = $space & $token & $space EndSelect Case $ampersand Select Case $previous_token = $space And $next_token <> $space $token = $token & $space Case $previous_token <> $space And $next_token = $space $token = $space & $token Case $previous_token <> $space And $next_token <> $space $token = $space & $token & $space EndSelect Case $plus, $minus, $asterisk, $forward_slash Switch $next_token = $equal Case True Select Case $previous_token = $space And StringMid($au3, $i + 2, 1) = $space $token = $token & $equal $i += 1 Case $previous_token <> $space And StringMid($au3, $i + 2, 1) <> $space $token = $space & $token & $equal & $space $i += 1 Case $previous_token = $space And StringMid($au3, $i + 2, 1) <> $space $token = $token & $equal & $space $i += 1 Case $previous_token <> $space And StringMid($au3, $i + 2, 1) = $space $token = $space & $token & $equal $i += 1 EndSelect EndSwitch Case $open_bracket, $open_parens, $open_angle_bracket Select Case $next_token = $space $i += 1 EndSelect Case $close_bracket, $close_parens, $close_angle_bracket Select Case $previous_token = $space $formatted_au3 = StringTrimRight($formatted_au3, 1) EndSelect EndSwitch EndSwitch $formatted_au3 &= $token Next Return $formatted_au3 EndFunc ;==>autoit_format #region ; strip_whitespace Func strip_whitespace(Const $au3) Local Const $au3_length = StringLen($au3) Local $formatted_au3 = '' Local $token = '' Local $within_line_feed = False For $i = 0 To $au3_length $token = StringMid($au3, $i, 1) Switch $token = $line_feed Case True $within_line_feed = Not $within_line_feed Case Else $within_line_feed = False EndSwitch Switch $within_line_feed Case True Switch $token Case $space ContinueLoop EndSwitch EndSwitch $formatted_au3 &= $token Next Return $formatted_au3 EndFunc ;==>strip_whitespace #endregion ; strip_whitespace #endregion ; autoit_format Here is an example which should test everything it can parse: expandcollapse popup#include <TEST.au3> #include < TEST.au3> #include <TEST.au3 > #include < TEST.au3 > Global Const $TEST=$TEST;$hDC=0,$tRECT=0 Global Const $TEST =$TEST ;$hDC =0,$tRECT= 0 Global Const $TEST= $TEST; $hDC= 0,$tRECT =0 Global Const $TEST= $TEST; $hDC= 0 ,$tRECT =0 Global Const $TEST= $TEST; $hDC= 0, $tRECT =0 MsgBox ( 0, "TEST","TEST" ) Global COnst $TEST[10]=[ '','','' ,'' , '', '' ] Global COnst $TEST[10] =[ '','','' ,'' , '', '' ] Global COnst $TEST[10]= [ '','','' ,'' , '', '' ] If $TEST==$TEST Then $TEST If $TEST ==$TEST Then $TEST If $TEST== $TEST Then $TEST $TEST = 100 += 100 $TEST = 100+=100 $TEST = 100 +=100 $TEST = 100+= 100 $TEST = 100 -= 100 $TEST = 100-=100 $TEST = 100 -=100 $TEST = 100-= 100 $TEST = 100 *= 100 $TEST = 100*=100 $TEST = 100 *=100 $TEST = 100*= 100 $TEST = 100 /= 100 $TEST = 100/=100 $TEST = 100 /=100 $TEST = 100/= 100 Check back for regular updates if you're interested. Edited July 31, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
BrewManNH Posted July 31, 2013 Share Posted July 31, 2013 Have you ever tried using Tidy? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 (edited) Have you ever tried using Tidy? Tidy does something I don't like which is it takes spaces away if there are more than one. I like to keep certain statements lined up in a particular way. Look seriously, I have been here since '08. You think by now I haven't tried using Tidy? It seems like an insult for you to ask me that. I'm actually kinda surprised by that. Maybe a llil hurt but I'll get over it. Edited July 31, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted July 31, 2013 Author Share Posted July 31, 2013 I still think it's nice to how it might be done in AutoIt. Thanks. My only question is why the ByRef Const for a string value? It's not a large block of data. 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 More sharing options...
jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 I still think it's nice to how it might be done in AutoIt. Thanks. My only question is why the ByRef Const for a string value? It's not a large block of data. I think it would be nice too. I want the learning experience more than anything. Glad some people can see that. It might be small now but it might be large in the future. That's my story and I'm sticking to it. Seriously though, I did it at first because I want to accomodate long file paths. I read here just now that Win8 can support a length of 32,000. I know, no one will ever use it but ok, I can always remove it if it's better. Also, if it's byref then that's only one string in memory instead of two. It is in keeping with my idea of minimizing duplication of data as much as possible. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted July 31, 2013 Author Share Posted July 31, 2013 (edited) Well recently I found out that as well as arrays having copy-on-write so does strings. I like you theory, but in this case the user still has to create a single variable if they want to call the function using a string value. Edit: Anyway that's only a minor point I have. Still nice that you posted here. Edited July 31, 2013 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 More sharing options...
jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 This demonstrates my justification for using ByRef on strings and arrays. Is this not necessary then? ; creates a variable in memory which has a lot of elements Global Const $my_global_variable[16777216] MyFunction($my_global_variable) ; creates yet another variable in memory which has a lot of elements Func MyFunction(const $my_local_variable) ; crunch $my_local_variable EndFunc ; creates a pointer in memory which still uses memory yes, ; but if $my_global_variable were huge ; then it would save memory Func MyFunction(const byref $my_local_variable) ; crunch on $my_local_variable EndFunc Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted July 31, 2013 Author Share Posted July 31, 2013 Not really, but it's good for consistency. Func SomeFunc($aArray) ConsoleWrite($aArray[0] & @CRLF) EndFunc ;==>SomeFunc ; Is the same as... Func SomeFunc(ByRef Const $aArray) ConsoleWrite($aArray[0] & @CRLF) EndFunc ;==>SomeFunc ; Or Func SomeFunc(ByRef $aArray) ConsoleWrite($aArray[0] & @CRLF) EndFunc ;==>SomeFunc ; This of course requires ByRef to pass as a reference, as the array is being manipulated... Func SomeFunc(ByRef $aArray) $aArray = '99 problems' ConsoleWrite($aArray[0] & @CRLF) EndFunc ;==>SomeFunc ; Search the Dev section for confirmation that arrays are copy-on-write. The point I was trying to make is your theory doesn't really apply in your example, but maybe this should be moved to 'best coding practices'? 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 More sharing options...
jaberwacky Posted July 31, 2013 Share Posted July 31, 2013 The point I was trying to make is your theory doesn't really apply in your example, but maybe this should be moved to 'best coding practices'? Yes, I need a good place to discuss this. It takes me a while to 'get' concepts. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted August 2, 2013 Author Share Posted August 2, 2013 Parsing comments in a script file. expandcollapse popup#include <Array.au3> #include <Constants.au3> Example() Func Example() ; Read the script file. Local $sData = FileRead(@ScriptFullPath) ; Convert comments to RANDOMSTRIG_COMMENTS_RAND_COMMENTS_RANDOMSTRIG. Local $hComments = _Comments_Get($sData) If ClipPut($sData) Then MsgBox($MB_SYSTEMMODAL, '', 'Copied example of replaced comments to the clipboard. Paste to see the result(s).') ; Expand the comments back their original format. _Comments_Set($hComments, $sData) If ClipPut($sData) Then MsgBox($MB_SYSTEMMODAL, '', 'Copied example of reverting comments to the clipboard. Paste to see the result(s).') EndFunc ;==>Example Func _Comments_Get(ByRef $sData) Local Enum $eCommentsSingle_AssociativeArray, $eCommentsSingle_Array, $eCommentsSingle_UniqueID, _ $eCommentsMulti_AssociativeArray, $eCommentsMulti_Array, $eCommentsMulti_UniqueID, $eComments_Max Local $aAPI[$eComments_Max] ; Create a random ID. SRandom(@HOUR & @MIN & @MSEC) For $i = 1 To 10 $aAPI[$eCommentsSingle_UniqueID] &= Chr(Random(65, 90, 1)) Next ; Create an associative array object. Local Const $sCommentsSingleAfter = '_' & $aAPI[$eCommentsSingle_UniqueID] & '_COMMENTSSINGLE', $sCommentsSingleBefore = 'COMMENTSSINGLE_' & $aAPI[$eCommentsSingle_UniqueID] & '_', _ $sCommentsSinglePattern = '(;[^\r\n]*)' _AssociativeArray_Startup($aAPI[$eCommentsSingle_AssociativeArray], True) ; Temporarily convert comments to a pre-defined format string. __PreProcessor_SRE($sData, $aAPI[$eCommentsSingle_Array], $aAPI[$eCommentsSingle_AssociativeArray], $sCommentsSinglePattern, $sCommentsSingleBefore, $sCommentsSingleAfter) ; Create a random ID. SRandom(@HOUR & @MIN & @MSEC) For $i = 1 To 10 $aAPI[$eCommentsMulti_UniqueID] &= Chr(Random(65, 90, 1)) Next ; Create an associative array object. Local Const $sCommentsMultiAfter = '_' & $aAPI[$eCommentsMulti_UniqueID] & '_COMMENTSMULTI', $sCommentsMultiBefore = 'COMMENTSMULTI_' & $aAPI[$eCommentsMulti_UniqueID] & '_', _ $sCommentsMultiPattern = '(?ims)^(\s*#(?:cs|comments-start)(?!\w).+?#(?:ce|comments-end))' _AssociativeArray_Startup($aAPI[$eCommentsMulti_AssociativeArray], True) ; Temporarily convert comments to a pre-defined format string. __PreProcessor_SRE($sData, $aAPI[$eCommentsMulti_Array], $aAPI[$eCommentsMulti_AssociativeArray], $sCommentsMultiPattern, $sCommentsMultiBefore, $sCommentsMultiAfter) Return $aAPI EndFunc ;==>_Comments_Get Func _Comments_Set(ByRef $aAPI, ByRef $sData) Local Enum $eCommentsSingle_AssociativeArray, $eCommentsSingle_Array, $eCommentsSingle_UniqueID, _ $eCommentsMulti_AssociativeArray, $eCommentsMulti_Array, $eCommentsMulti_UniqueID, $eComments_Max #forceref $eCommentsSingle_UniqueID, $eCommentsMulti_UniqueID If UBound($aAPI) <> $eComments_Max Then Return False EndIf ; Converting comments back to their original state. Local $fReturn = __PreProcessor_SRE_Replace($sData, $aAPI[$eCommentsMulti_Array], $aAPI[$eCommentsMulti_AssociativeArray]) $fReturn += __PreProcessor_SRE_Replace($sData, $aAPI[$eCommentsSingle_Array], $aAPI[$eCommentsSingle_AssociativeArray]) Return $fReturn = 2 EndFunc ;==>_Comments_Set #region Functions - Taken from various parsing scripts of mine. #Obfuscator_Off Func _AssociativeArray_Startup(ByRef $aArray, $fIsCaseSensitive = False) ; Idea from MilesAhead. $aArray = ObjCreate('Scripting.Dictionary') ObjEvent('AutoIt.Error', '__AssociativeArray_Error\\\') If IsObj($aArray) = 0 Then Return SetError(1, 0, 0) EndIf $aArray.CompareMode = Int(Not $fIsCaseSensitive) EndFunc ;==>_AssociativeArray_Startup #Obfuscator_On Func _GenerateUniqueIndex($iValue) ; Idea taken from __Array_Combinations. Local Const $UNIQUE_CHRS = 26 Local $iChrs = 0, $iStep = 0, $iTotal = 0 Do $iChrs = $UNIQUE_CHRS $iStep += 1 $iTotal = 1 For $i = $iStep To 1 Step -1 $iTotal *= ($iChrs / $i) $iChrs -= 1 Next Until $iValue <= $iTotal Return $iStep EndFunc ;==>_GenerateUniqueIndex Func _GenerateUniqueStrings($iSet = Default) ; By Beege, modified by guinness. 2011-2013. Local Static $fIsUniqueArray = False If $iSet = Default Then $iSet = 4 If Not $fIsUniqueArray Then $fIsUniqueArray = True Local Const $iSPUBound = 2 Local $aArray = StringSplit('A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z', '|', $iSPUBound) EndIf Local Static $aUnique = _ArrayCombinations($aArray, 4) Return $aUnique EndFunc ;==>_GenerateUniqueStrings Func _StringRegExpMetaCharacters($sString) Return StringRegExpReplace($sString, '([].|*?+(){}^$\\[])', '\\\1') EndFunc ;==>_StringRegExpMetaCharacters #endregion Functions - Taken from various parsing scripts of mine. #region Pre-Processor Functions Func __PreProcessor_SRE(ByRef $sData, ByRef $aArray, ByRef $hStrings, $sSREPattern, $sStringsBefore, $sStringsAfter, $sCheckBefore = Default, $sCheckAfter = Default, $iIndex = Default, $iStep = Default, $fExitFirstRound = Default) Local Enum $eStrings_Data, $eStrings_Index, $eStrings_Key, $eStrings_Max $iIndex = Int($iIndex) If $iIndex <= 0 Then $iIndex = 1 EndIf If $iStep = Default Then $iStep = 2 EndIf If $sCheckAfter = Default Then $sCheckAfter = '' If $sCheckBefore = Default Then $sCheckBefore = '' Local $aSRE = 0, $aUnique = _GenerateUniqueStrings(), _ $aStrings[1][$eStrings_Max] = [[0, $eStrings_Max]], _ $iCount = 1 Local $hStringsTemp = 0 _AssociativeArray_Startup($hStringsTemp, True) While 1 $aSRE = StringRegExp($sData, $sSREPattern, 3) If UBound($aSRE) = 0 Then ExitLoop ReDim $aStrings[$aStrings[0][0] + UBound($aSRE) + 1][$aStrings[0][1]] $iCount = $aStrings[0][0] + 1 For $i = 0 To UBound($aSRE) - 1 Step $iStep If Not $hStringsTemp.Exists($aSRE[$i]) Then $hStringsTemp($aSRE[$i]) = $aSRE[$i] $aStrings[0][0] += 1 $aStrings[$aStrings[0][0]][$eStrings_Data] = $aSRE[$i] $aStrings[$aStrings[0][0]][$eStrings_Index] = 0 $aStrings[$aStrings[0][0]][$eStrings_Key] = '' EndIf Next $hStringsTemp = 0 _AssociativeArray_Startup($hStringsTemp, True) For $i = $iCount To $aStrings[0][0] $aStrings[$i][$eStrings_Index] = $aUnique[$iIndex] $aStrings[$i][$eStrings_Key] = $sStringsBefore & $aStrings[$i][$eStrings_Index] & $sStringsAfter ; Replace the quote strings with temporary strings. ; '\Q' & $aStrings[$i][$eStrings_Data] & '\E' $sData = StringRegExpReplace($sData, $sCheckBefore & _StringRegExpMetaCharacters($aStrings[$i][$eStrings_Data]) & $sCheckAfter, $aStrings[$i][$eStrings_Key]) If @extended Then $hStrings($aStrings[$i][$eStrings_Key]) = $aStrings[$i][$eStrings_Data] Else $sData = StringReplace($sData, $aStrings[$i][$eStrings_Data], $aStrings[$i][$eStrings_Key]) ; For replacing \Q and \E. If @extended Then $hStrings($aStrings[$i][$eStrings_Key]) = $aStrings[$i][$eStrings_Data] Else $aStrings[$i][$eStrings_Data] = '' $aStrings[$i][$eStrings_Index] = 0 $aStrings[$i][$eStrings_Key] = '' EndIf EndIf $iIndex += 1 Next If $fExitFirstRound Then ExitLoop EndIf WEnd $aSRE = 0 ReDim $aStrings[$aStrings[0][0] + 1][$aStrings[0][1]] $aArray = $aStrings Return $iIndex EndFunc ;==>__PreProcessor_SRE Func __PreProcessor_SRE_Replace(ByRef $sData, ByRef $aStrings, ByRef $hStrings) Local Enum $eStrings_Data, $eStrings_Index, $eStrings_Key, $eStrings_Max #forceref $eStrings_Data, $eStrings_Max Local $iReplaced = 0 For $i = $aStrings[0][0] To 1 Step -1 If $aStrings[$i][$eStrings_Index] And $hStrings.Exists($aStrings[$i][$eStrings_Key]) Then $sData = StringReplace($sData, $aStrings[$i][$eStrings_Key], $hStrings($aStrings[$i][$eStrings_Key])) $iReplaced += @extended EndIf Next Return $aStrings[0][0] = $iReplaced EndFunc ;==>__PreProcessor_SRE_Replace #endregion Pre-Processor Functions 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 More sharing options...
guinness Posted December 22, 2013 Author Share Posted December 22, 2013 Dummy Au3 Script for parsing. expandcollapse popupCreate() ; Copied to the clipboard. Func Create() SRandom(@SEC) Local $aKeyword[6] = ['Const', 'Local Const', 'Global Const', _ 'Enum', 'Local Enum', 'Global Enum'], _ $iEnumValue = 0, $iIndex = 0, $sEnumValue = '', $sReturn = '', $vValue = 0 Local Enum $eBOOLEAN, $eENUM, $eMACRO, $eNUMBER, $eSTRING For $i = 1 To 50 $sReturn &= $aKeyword[Random(0, 2, 1)] For $j = 1 To Random(1, 5, 1) $iIndex += 1 Switch Random($eBOOLEAN, $eSTRING, 1) Case $eBOOLEAN $vValue = _If() = _If() Case $eMACRO $vValue = '@ScriptDir' Case $eNUMBER $vValue = Random(1, 1000, _If()) Case $eSTRING $vValue = '"Some String Number ' & $iIndex & '"' EndSwitch $sReturn &= ' $CONST_VAR_' & $iIndex & ' = ' & $vValue & ',' Next $sReturn = StringTrimRight($sReturn, StringLen(',')) & @CRLF If Random(1, 5, 1) = $eENUM Then $iEnumValue = 0 $sReturn &= $aKeyword[Random(3, 5, 1)] For $j = 1 To Random(1, 10, 1) $iIndex += 1 If _If() Then $iEnumValue += Int(Random(1, 100, 1)) $sEnumValue = _Ternary(_If(), ' = ' & $iEnumValue, '') EndIf $sReturn &= ' $CONST_VAR_' & $iIndex & $sEnumValue & ',' $sEnumValue = '' Next $sReturn = StringTrimRight($sReturn, StringLen(',')) & @CRLF EndIf Next For $i = 1 To $iIndex $sReturn &= 'ConsoleWrite($CONST_VAR_' & $i & ' & @CRLF)' & @CRLF Next ConsoleWrite($sReturn & @CRLF) ClipPut($sReturn) EndFunc ;==>Create Func _If() Return Random(0, 1, 1) EndFunc ;==>_If Func _Ternary($vTest, $vTrue, $vFalse) ; Wrapper for the ternary statement. ; Return ($vTest) ? $vTrue : $vFalse Local $aArray[2] = [$vFalse, $vTrue] Return $aArray[Int(Int($vTest) > 0)] EndFunc ;==>_Ternary 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 More sharing options...
guinness Posted December 24, 2013 Author Share Posted December 24, 2013 Updated post >#20 with the api of v3.3.10.0. 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 More sharing options...
guinness Posted December 24, 2013 Author Share Posted December 24, 2013 Updated post >#7 for parsing the au3.api file. I removed IsDeclared() and Assign() for creating a unique array and opted for using a scripting.dictionary object. 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 More sharing options...
guinness Posted January 15, 2014 Author Share Posted January 15, 2014 Parsing Functions #include <Array.au3> Example() Func Example() Local $aArray = 0, $sData = FileRead(@ScriptFullPath) _GetFunctions($sData, $aArray) ; Produces an array with Function + FuncName. If UBound($aArray) Then _ArrayDisplay($aArray) EndFunc ;==>Example Func _GetFunctions(ByRef $sData, ByRef $aArray) $aArray = StringRegExp($sData & @CRLF, '(?ims)(^Func(?=\h)\h+(\w+)\h*\(.*?(?<=\r|\n|\r\n)EndFunc(?=\R|\s))', 3) EndFunc ;==>_GetFunctions 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 More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 I used your >function for removing comments, thanks. Suggestion for improvement would be, the part that removes a comment which is on a line of its own, to also remove the empty line left. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted January 15, 2014 Author Share Posted January 15, 2014 JohnOne, I've updated the functions. 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 More sharing options...
guinness Posted January 15, 2014 Author Share Posted January 15, 2014 Updated the following for today: 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 More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 Does not appear to work mate. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted January 15, 2014 Author Share Posted January 15, 2014 Oh well, I dunno what you wanted then. 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 More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 No worries, should be simple to implement in separate function. If I have this script.au3. $var = $var2 ;script does nothing ;its just an example ;of what I meant $var2 = $var And I use your function to remove comments, I'm left with... $var = $var2 $var2 = $var Where I thought it would be an improvement to be left with... $var = $var2 $var2 = $var AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now