czardas Posted September 18, 2012 Share Posted September 18, 2012 (edited) Ternary is too. This reminds me, I recently discovered some mistakes in the (my own) documentation, I need to update it. It's a job for later on today. Edited September 18, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted September 18, 2012 Share Posted September 18, 2012 (edited) I recently discovered some mistakes in the documentation, I need to update it. It's a job for later on this today.Great. Just post in the help file thread I would look at it in due course.Edit: Whoops! I re-read it and realised it was your documentation. Edited September 18, 2012 by guinness czardas 1 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...
skin27 Posted September 18, 2012 Share Posted September 18, 2012 High order functions, objects, threads etc are great when writing larger programs with AutoIt. In practice most of the time I just needed a simple code snippet (which is mostly available on the wiki if not in the help file).Another perspective is not from a language construct, but from a first time programmer (where nothing is implied). For example I had some moments where I was confused on its Basic-like syntax. Some examples:1) EqualityWhen you compare something it must be of the same type, for example; If int = int then trueIf 1 = 1 then ConsoleWrite("true"); Ok, that works as expected. However the following valid statement returns always falseIf 1 = not(2) then ConsoleWrite("true"); So I compared an int with the boolean false, so I have to write something like this:If 1 <> 2 then ConsoleWrite("true")orIf StringCompare ( "1", "2", 1) <> 0 then ConsoleWrite("true")To get equality between int, string. Such syntax would be clearer to meIf 1 not = 2 then ConsoleWrite("true")orIf 1 != 2 then ConsoleWrite("true")2) arraysTo work with arrays you can typically use Basic statements like Ubound, Dim, RedimWith the current use function naming conventions I would opt for Ubound - 1 --> ArraySize ReDim --> ArrayResizeWhich new programmer would search for Ubound or ReDim? I also got confused that most of the time you can use array[0] to get the array size, while on other occasions you need Ubound. Side note: I would like to work with (i.e. Vector) collections, instead of just arrays. Needs less low level work.3) The following seems to me some historic usage of the Basic syntax.For example the conditional statement have the following syntaxIf --> EndIfSelect --> EndSelectSwitch --> EndSwitchWith --> EndWithBut loopsWhile --> WEndFor --> NextDo --> UntilWhen just looking at logic of the loop this seems logical, but when looking to the whole language why not do the following:While --> EndWhileFor...To --> EndForForeach ... in .. EndForeachDo --> EndDoIf the logic on loops needs to be kept then I would suggest to use While --> Done, instead of While --> WEnd 3) Besides includes it would be nice to define a package/project, so when working with multiple file the init (main) file will always be started.4) Template expressionThis would make codes with multiple lines easier to work with. Like I posted on example script: ressionNew JVM languages like Kotlin, Xtend and Ceylon have good support for this.5) RunDosWhen I first started to use _RunDos I would expect that it equals to Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE). Then there is ConsoleWrite/ConsoleRead which only works in a CUI. Found it all a bit confusion when working with the console. Couldn't this be reworked (like Mat's UDF for this)?Ok, in my examples I still wrote about some language constructs like packages, collections and template expressions, but I hope the examples on a different perspective from a newbie point-of-view adds also something to this discussion. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 18, 2012 Author Share Posted September 18, 2012 3) 'End' keyword to close all control structures. Preprocessor does an automatic conversion to correct keyword to match last used control structure. For example, input: While True Sleep(500) End Preprocesses into: While True Sleep(500) WEnd It's a trivial thing, but can be convenient. 4) Multi-line strings. Why didn't I think of that? Pick any syntax (up for debate on this), I would prefer: $a = [[This is a multi line string.]] Preprocesses into: $a = "This is" & @CRLF & _ "a multi" & @CRLF & _ "line string." @CRLF, @LF or @CR can be determined by what characters you use in your source file. github.com/jvanegmond Link to comment Share on other sites More sharing options...
dany Posted September 18, 2012 Share Posted September 18, 2012 4) Multi-line strings. Why didn't I think of that? Pick any syntax (up for debate on this), I would prefer: $a = [[This is a multi line string.]] Preprocesses into: $a = "This is" & @CRLF & _ "a multi" & @CRLF & _ "line string." Like HereDoc strings. Yea that would be a very nice addition, got my vote. As far as syntax goes, [[Lua or the more unofficial standard <<HEREDOC style, well, I'd go for the <<HEREDOC style, Lua is somewhat ambiguous imho as it looks like an array assignment. $a = <<HEREDOC_END This is a multi line string. HEREDOC_END [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
James Posted September 18, 2012 Share Posted September 18, 2012 I +1 Heredocs. Since variable identifier $ is now optional, it should be mandatory to wrap variables to be printed in mustaches {{}} or even how Ruby does it #{variable} Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Mat Posted September 18, 2012 Share Posted September 18, 2012 People have done this before, to implement features such as classes using a pre-processor. AutoIt Project Listing Link to comment Share on other sites More sharing options...
jvanegmond Posted September 18, 2012 Author Share Posted September 18, 2012 People have done this before, to implement features such as classes using a pre-processor. github.com/jvanegmond Link to comment Share on other sites More sharing options...
guinness Posted September 19, 2012 Share Posted September 19, 2012 The preprocessor converts out constant values. ; Before Local Const $iValue = 10 MsgBox(4096, '', $iValue) ; After MsgBox(4096, '', 10) ; Replaces $iValue with the respective value. jvanegmond 1 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...
jvanegmond Posted September 19, 2012 Author Share Posted September 19, 2012 The preprocessor converts out constant values. ; Before Local Const $iValue = 10 MsgBox(4096, '', $iValue) ; After MsgBox(4096, '', 10) ; Replaces $iValue with the respective value. Doesn't AutoIt do this internally in the lexing or parsing stage? github.com/jvanegmond Link to comment Share on other sites More sharing options...
guinness Posted September 19, 2012 Share Posted September 19, 2012 Doesn't AutoIt do this internally in the lexing or parsing stage?It's something I have wondered in the past. 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...
jvanegmond Posted September 19, 2012 Author Share Posted September 19, 2012 (edited) It's something I have wondered in the past.Poking around in v3.3.8.1 says no.Edit: I'm not a fan of preprocessing for speed, though. It's extremely hard because it's hard to predict. It also puts focus in the wrong place. It distorts responsibilities. Edited September 19, 2012 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Mat Posted September 19, 2012 Share Posted September 19, 2012 Poking around in v3.3.8.1 says no.Eval("iValue") probably says no too. AutoIt Project Listing Link to comment Share on other sites More sharing options...
trancexx Posted September 20, 2012 Share Posted September 20, 2012 Const var is just like non-const one. The only difference is different flag which is set and read by the parser. Lexer makes no difference. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted September 20, 2012 Share Posted September 20, 2012 (edited) @CRLF, @LF or @CR can be determined by what characters you use in your source file.Perhaps I misunderstand this. You don't want to lose control of formatting: considering there are inconsistancies between third party applications which could cause no end of problems. Thinking about the code boxes on this forum, as an example. Edited September 20, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
guinness Posted September 20, 2012 Share Posted September 20, 2012 Const var is just like non-const one. The only difference is different flag which is set and read by the parser. Lexer makes no difference.Thanks for clarifying. It's what I thought happened. 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...
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