square65 Posted February 20, 2015 Share Posted February 20, 2015 I know this seems like a question that could easily be handled by the documentation. Amazingly it doesn't. And googling returns nothing. Not a single person doing this or asking how to do this. I've tried: $test[][] = 0 $test[][] = [[]] And a ton of other variations on this. Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 I've figured out how. You need to preface your array declaration with a scope specifier. A la: Local $test[][] Global $test[][] Since this is covered nowhere, hopefully when a good programmer is asking how to declare an array without initializing it to arbitrary values, they will come across this post. Link to comment Share on other sites More sharing options...
iamtheky Posted February 20, 2015 Share Posted February 20, 2015 If only there was a help file Language Reference - Variables ... Before you can start using Arrays in your script, you must define their bounds using the 'Global/Local/Static' keywords and define the bounds or assign some of the elements. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
qwert Posted February 20, 2015 Share Posted February 20, 2015 (edited) I agree that arrays are a little nebulous in the au3 documentation. Here's a little excerpt from the help that clearly shows the mechanism (including the 0-based indexing): #include <Array.au3> Local $aArray_Base[10][3] For $i = 0 To 9 For $j = 0 To 2 $aArray_Base[$i][$j] = $i & " - " & $j Next Next _ArrayDisplay($aArray_Base, "2D - Original") The best long-term solution would be additions to the help that are clearly labeled as 1-dimensional, 2-dimensional and, say, 3-dimensional arrays ... as separate topics. Edited February 20, 2015 by qwert GoogleGonnaSaveUs 1 Link to comment Share on other sites More sharing options...
Developers Jos Posted February 20, 2015 Developers Share Posted February 20, 2015 From the Helpfile: Language Reference - Variables Before you can start using Arrays in your script, you must define their bounds using the 'Global/Local/Static' keywords and define the bounds or assign some of the elements. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
MikahS Posted February 20, 2015 Share Posted February 20, 2015 (edited) A good programmer wouldn't knock a language they don't know.. EDIT: Let me google that for you Edited February 20, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 20, 2015 Moderators Share Posted February 20, 2015 square65,There is always the Arrays tutorial in the Wiki which is very comprehensive. 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...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 If only there was a help file Lmao. If only consulting a page like: https://www.autoitscript.com/wiki/Arrays Was sufficient for just declaring a basic array. Melba23, that article, which is actually the one I consulted before this post, does not explicitly state you need to give the scope specifier. It just shows that in an example. But you can give any variable that specifier and generally don't need to therefore it makes sense to ignore it in that tutorial. MikahS, as I said, I consulted that and for logical reasons did not realize the scope specifier was absolutely necessary. I am a good programmer. Just not necessarily in this language yet. But I am a better programmer than you. Also the script I wrote last week, the first week I'd ever even heard of Autoit, is probably more sophisticated than anything you could write. It does full blown image processing, edge detection, and a pseudo image recognition system. Thanks for the condescending LMGTFY though. Really showed that you lacked the intelligence to recognize that my question was actually legitimate and that obviously, based on my intelligent wording, I'd already consulted that page. Thanks for the kind meaning advice from three of you. And I hope you learned your lesson, the condescending two of you. I have a way of putting people in their place when they step out of line professionally. I do it in my job and I have the most productive IT department across every branch of my company. Hope you learned something *snaps fingers, winks, spins 360 degrees and walks away* Lock this thread please. Link to comment Share on other sites More sharing options...
iamtheky Posted February 20, 2015 Share Posted February 20, 2015 You have done nothing of the sort, word walls in coding forums should probably include actual code, otherwise it is nonsense. Tell us more about this awesome first project......that obviously doesnt use arrays. MikahS 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 It uses arrays Maybe you misunderstood this post. Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 In fact it uses arrays of an arbitrary declared-at-runtime number of dimensions. Ever even heard of something like that? Link to comment Share on other sites More sharing options...
MikahS Posted February 20, 2015 Share Posted February 20, 2015 Are you going to post it or keep running your mouth? Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 I said or hinted I was going to? http://lmgtfy.com/?q=proprietary Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 (edited) Let me be clear. I'm a civil guy. But long time members on forums develop a VERY condescending attitude to newbies. I have never abided that. And I never will. You guys got what you asked for. Edited February 20, 2015 by square65 Link to comment Share on other sites More sharing options...
qwert Posted February 20, 2015 Share Posted February 20, 2015 Flame me if you want, but I have to speak up, here: The content and tone of the posts on this topic do a real disservice to the OP, the community and the AU3 language. A LOT of people here are beginners. The help file is a sprawling and continually-evolving work ... and sometimes the answer isn't obvious to even a veteran of the language. (In 6 years, I've had my share of those experiences.) Anyone who doesn't feel like answering a simple question should refrain from posting. Someone else will probably chime in with a meaningful response. I don't see the value of "snips". And they're as unsightly on a forum as litter is on a roadside. Link to comment Share on other sites More sharing options...
square65 Posted February 20, 2015 Author Share Posted February 20, 2015 Thanks. I feel the same way. I appreciate the answers I got. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 20, 2015 Moderators Share Posted February 20, 2015 And everyone please take a deep breath before someone oversteps the mark (which has already been approached pretty closely) and I have to put on my Mod hat... square65,I agree that the documentation does not appear to have a note of the requirement for arrays to be scoped on declaration in all cases - which makes me wonder why no-one has ever raised the point before. Perhaps everyone else did "realize the scope specifier was absolutely necessary", despite not being as good a programmer as your good self. I will add something to the "Array" section of the "Language Reference - Variables" page and to the "Arrays" Wiki tutorial for the enlightenment of future searchers. M23 Tekk 1 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...
mikell Posted February 20, 2015 Share Posted February 20, 2015 (edited) Hmm refering to post #2 I'm interested in declaration of empty arrays I'm running the 3.3.12.0 release Global $test[][] Global $test[^ ERROR Error: Variable subscript badly formatted. But this works #Include <Array.au3> Global $test[][] = [[1, 2], [3, 4]] _ArrayDisplay($test) So IMHO this thread is not completely useless (forgetting messages > #2) Edit And I could find nowhere in the helpfile a mention about how to declare an empty array using this kind of syntax Edited February 20, 2015 by mikell Link to comment Share on other sites More sharing options...
BrewManNH Posted February 20, 2015 Share Posted February 20, 2015 Declaring a variable like this creates a Map type variable, in 3.3.13.x beta versions. Global $Test[] Going above 1 dimension means you HAVE to declare the array with something in it if you don't say how many elements are in the dimensions. If you want your array to BE an array with one dimension, then you have to include the size in the declaration statement. 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...
mikell Posted February 20, 2015 Share Posted February 20, 2015 BrewManNH, Thanks, I really thought about something like this Your message should have been #3 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