Thimotty Posted April 20, 2015 Share Posted April 20, 2015 #include <Array.au3> global $arr[2][2] $arr[0]['x'] = 11 $arr[0]['y'] = 22 $arr[1]['x'] = 33 $arr[1]['y'] = 44 displayArray($arr) Func displayArray($array) For $i = 0 to UBound($array, 1) - 1 MsgBox(0,"AutoIt",$array[$i]['x']) MsgBox(0,"AutoIt",$array[$i]['y']) Next EndFunc I expect 4 boxes with text 11...22...33...44 instead i get 22...22...44...44 What am i doing wrong? Link to comment Share on other sites More sharing options...
Zedna Posted April 20, 2015 Share Posted April 20, 2015 (edited) Use only numbers as array index, not strings. AutoIt probably does implicit conversion from 'X' and 'y' to number which is probably the same (zero or non-zero number). Edited April 20, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted April 20, 2015 Share Posted April 20, 2015 (edited) If you need strings as indexes then use Scripting.Dictionary (object) or new AutoIt's syntax of Maps (not arrays) which I'm not familiar with ... but details are in the helpfile. Edited April 20, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Thimotty Posted April 20, 2015 Author Share Posted April 20, 2015 Thank you Zedna, you are correct. I've replaced 'x','y' with '1x','2y' and it worked. Thank you very much. It is very strange to me that autoit does not have associative arrays, deep arrays and foreach function. Link to comment Share on other sites More sharing options...
Zedna Posted April 20, 2015 Share Posted April 20, 2015 Open AutoIt's helpfile ("C:Program FilesAutoIt3AutoIt.chm") and go to section: Language reference/variables ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Thimotty Posted April 20, 2015 Author Share Posted April 20, 2015 and...? Link to comment Share on other sites More sharing options...
Zedna Posted April 20, 2015 Share Posted April 20, 2015 (edited) And you will find answers to all your questions (placed here) ;-) especially about arrays/maps also with very nice examples Edited April 20, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Thimotty Posted April 20, 2015 Author Share Posted April 20, 2015 (edited) ahh Actually nope! I won't It does not say anything about associative arrays. I have naturally assumed a high level lang should be able to handle string keys and it didn't even cross my mind that "index numbers" should be taken literally It does speak of multidimentional arrays but does not mention they are actually matrix and not array or arrays like the other langs. I can store matrix data only in matrix values and can't use the keys the same way. I wouldn't know that if i haven't read it in the forums here. The "UBound" workaround of foreach is not actual replacement Here is an example: I have incoming a simple text file with unknown count of x,y coordinates which i want to load and use. For example in perl my original script from this thread would look like this: $arr{11}=22; $arr{33}=44; ... foreach $key (keys %arr) { print "X->" . $key . " ,Y-> " . $arr{$key}; } In PHP it would be even simpler Try to write it in autoit and you'll see what i mean and why i got confused And i don't even want to think how complex the definition will get if i have z coord too Edited April 20, 2015 by Thimotty Link to comment Share on other sites More sharing options...
guinness Posted April 21, 2015 Share Posted April 21, 2015 (edited) PHP has it's problems as well. Also it's an array, AutoIt has never pretended that it's anything but that. Edited April 21, 2015 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...
guinness Posted April 21, 2015 Share Posted April 21, 2015 . The "UBound" workaround of foreach is not actual replacement You really should read the help file, even though I know you won't. Local $aArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] For $iNum In $aArray ConsoleWrite($iNum & @CRLF) Next 4 posts in and you're already exhibiting the attitude of someone who won't last very long around here. I like to think people can change, but given the way you conversed with Zedna, when they provided clear help and advice, shows me your lack of respect to those who know more about the language (AutoIt) than you. 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...
Thimotty Posted April 21, 2015 Author Share Posted April 21, 2015 No, guinness, probably i won't. I did thank Zedna properly, i think. When i share s simple thought that something is strange for me to be send to "go RTFM" or "google it" is considered kinda rude. When i try to explain what and why did confused me to be told that i am "exhibiting the attitude" and I "won't last very long around here" is absolutely rude. Yes i know they are called hashes in perl and php has it's problems but they still are (or can be used as) arrays of arrays. Please, old dog, do not assume that someone has not read the manual, especialy when same one explains what confused him in the manual I am sorry if you or anyone else feel that my posts are offensive, when they are not! Your attitude (and very likely what follows) will drive me away. Best regards and take it easy! Xandy 1 Link to comment Share on other sites More sharing options...
Zedna Posted April 21, 2015 Share Posted April 21, 2015 (edited) Asking very basic questions can be considered rude too. I was going to tell you about FOR IN LOOP but guinness was faster. As he said you don't read helpfile well else you couldn't write that AutoIt can't handle this/that ... for example arrays in arrays are posiible too. EDIT: You also posted in wrong section of this forum and you used absolutely wrong titile of topic :-( Edited April 21, 2015 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Thimotty Posted April 21, 2015 Author Share Posted April 21, 2015 (edited) Yes they are possible but you can't use them unless you get tem out of the array into another variable. Anyway Please accept my apologies for beeg rude and asking so basic question. Thank you again for your kind help! Edit: Yes i apologize for that too. Asking programing question in developers chat was really rude. Please don't be too mad at me! Edited April 21, 2015 by Thimotty 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