jguinch Posted December 31, 2015 Share Posted December 31, 2015 Hello all.Sometimes, i use this kind of array declaration :Local $a = [1, $a[0] ]This method of declaration worked before (I don't know which version, few monthes ago).Is it a desired behavior, or a bug ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2015 Moderators Share Posted December 31, 2015 jguinch,I am quite surprised that you say it used to work - I seem to remember this being discussed some time ago and the general consensus at the time was that such behaviour was not a good idea. So I would say: "feature", not "bug"M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
trancexx Posted December 31, 2015 Share Posted December 31, 2015 Of course it worked. The feature was controlled by Opt("MustDeclareVars").This is script breaking change, which apparently isn't documented. If there was "general consensus" on this, then I question the ability of participants to make decisions like that. minxomat 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
jguinch Posted December 31, 2015 Author Share Posted December 31, 2015 It worked next year : https://www.autoitscript.com/forum/topic/159554-paper-rock-scissors-challenge/?do=findComment&comment=1157805, https://www.autoitscript.com/forum/topic/160024-lottery-challenge/?do=findComment&comment=1162414It doesn't matter, but I wanted to be sure it was a desired change, not a bug ... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2015 Moderators Share Posted December 31, 2015 jguinch,It seems my memory was not correct in this instance - sorry to have misled you.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jguinch Posted December 31, 2015 Author Share Posted December 31, 2015 no problem Melba Now, I agree with trancexx : something should appear in the help file about this breaking change... Perhaps I should create a ticket in the bug tracker ? Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
jguinch Posted December 31, 2015 Author Share Posted December 31, 2015 Ahh, note it is possible do use something like this to skip this restriction :Local $a = [1, Execute("$a[0]") ] Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
czardas Posted December 31, 2015 Share Posted December 31, 2015 (edited) Ahh, note it is possible do use something like this to skip this restriction :Local $a = [1, Execute("$a[0]") ]That isn't a viable solution because Execute() interprets the input as if it were a string - who knows what kind of data that will return.I also have to agree with trancexx: it seems odd that this doesn't simply work out of the box. I am surprised that this (apparently logical) syntax no longer works. Edited December 31, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jguinch Posted December 31, 2015 Author Share Posted December 31, 2015 Yes czardas, I tought about that. I made some tests before my previous post and it seems to be not so bad : #include <Array.au3> Local $b = [1, "a", ObjCreate("shell.application"), WinList(), True, Binary("0x00204060") , DllStructCreate("int;"), WinGetHandle("[ACTIVE]"), MsgBox, 3.14159, 50, _ Execute("$b[0]"), Execute("$b[1]"), Execute("$b[2]"), Execute("$b[3]"), Execute("$b[4]"), Execute("$b[5]"), Execute("$b[6]"), Execute("$b[7]"), Execute("$b[8]"), Execute("$b[9]") ] ConsoleWrite("$b[11] is an integer ? " & IsInt($b[11]) & @CRLF) ConsoleWrite("$b[12] is a string ? " & IsString($b[12]) & @CRLF) ConsoleWrite("$b[13] is an object ? " & IsObj($b[13]) & @CRLF) ConsoleWrite("$b[14] is an array ? " & IsArray($b[14]) & @CRLF) ConsoleWrite("$b[15] is boolean ? " & IsBool($b[15]) & @CRLF) ConsoleWrite("$b[16] is binary ? " & IsBinary($b[16]) & @CRLF) ConsoleWrite("$b[17] is a structure ? " & IsDllStruct($b[17]) & @CRLF) ConsoleWrite("$b[18] is a handle ? " & IsHWnd($b[18]) & @CRLF) ConsoleWrite("$b[18] is pointer ? " & IsPtr($b[18]) & @CRLF) ConsoleWrite("$b[19] is function ? " & IsFunc($b[19]) & @CRLF) ConsoleWrite("$b[20] is float ? " & IsFloat($b[20]) & @CRLF) ConsoleWrite("$b[21] is number ? " & IsNumber($b[21]) & @CRLF) _ArrayDisplay($b) czardas 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
czardas Posted December 31, 2015 Share Posted December 31, 2015 (edited) Duh you are right, now I see my mistake. It's rather odd that the elements can't be referenced directly, yet they can still be accessed using Execute(). Edited December 31, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted December 31, 2015 Share Posted December 31, 2015 (edited) I'm surprised that this doesn't work:Local $a[] = [0] Local $a[] = [$a[0]]... but then again, neither does this:Local $a[] = [1] Local $a[] = [Execute('$a[0]')] Edited December 31, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jguinch Posted December 31, 2015 Author Share Posted December 31, 2015 (edited) Logical, because you use Local to declare the variable, so it's like the first use...This one works :Local $a = [1] Local $a[ $a[0] ] = [2] Edited December 31, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
czardas Posted December 31, 2015 Share Posted December 31, 2015 (edited) I wasn't aware of these restrictions on variable redeclaration. I thought the full expression was parsed evaluated before any impact on the original. That would seem consistent (syntax).;Local $sStr = "string" ;Local $sStr = $sStr & $sStr ; error $sStr = "string" $sStr = $sStr & $sStr ; assignment works alright hereEdit: Perhaps it's just simpler for things to be the way they are. Edited December 31, 2015 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
czardas Posted January 2, 2016 Share Posted January 2, 2016 I revise what I said in post #8. This is less intuitive than I at first thought: self-referencing (previous post) is not the same as back-referencing (first post). The syntax simply looked as though it ought to do something, although I haven't used it myself. I can see it being useful in both cases, but I don't know how other languages deal with this kind of thing. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
trancexx Posted January 2, 2016 Share Posted January 2, 2016 ^^ For example, intuitive as you are, do you think C/C++ allows this:char czardas[] = { 99, 122, 97, 114, 100, czardas[2], 115, 0 }; czardas 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted January 2, 2016 Share Posted January 2, 2016 My intuition sometimes lets me down, but I like your example. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 2, 2016 Moderators Share Posted January 2, 2016 Hi,I have been racking my ageing brain trying to come up with a use case when such a "self-initialisation" functionality would be required - and signally failing to do so. The other thread participants appear to believe that the functionality should still exist, so could one of them please provide a sensible real-world example - rather than the "fun" scripts linked to in post #4 above.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
czardas Posted January 2, 2016 Share Posted January 2, 2016 How about this - any use?Local $aReplicate[] = [Random(0, 1, 1), ($aReplicate[0] ? True : False)] operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
trancexx Posted January 2, 2016 Share Posted January 2, 2016 I would say that sensible real-world example would be any script that used to work and now it doesn't. minxomat 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
guinness Posted January 2, 2016 Share Posted January 2, 2016 The code that was referenced earlier, my code, worked in v3.3.12.0 (just tested it a second a go). So seems to be a bug with the latest version. 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