<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.autoitscript.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DoubleMcLovin</id>
	<title>AutoIt Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.autoitscript.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DoubleMcLovin"/>
	<link rel="alternate" type="text/html" href="https://www.autoitscript.com/wiki/Special:Contributions/DoubleMcLovin"/>
	<updated>2026-04-21T23:01:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=11621</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=11621"/>
		<updated>2013-03-03T01:15:26Z</updated>

		<summary type="html">&lt;p&gt;DoubleMcLovin: /* Comparing Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
== Initial notes ==&lt;br /&gt;
&lt;br /&gt;
This is a small tutorial on how to use arrays in AutoIt.&lt;br /&gt;
&lt;br /&gt;
We will try to target those people learning a programming language for the first time. So, be prepared for some spoon feeding.&lt;br /&gt;
&lt;br /&gt;
The code assumes you use the SciTE editor.  There is a minimal version of SciTE included in the latest stable release of AutoIt (version 3.2.0.1 and above).  To understand how arrays and associated functions work, it is imperative that you try and play with the samples that we provide here.  Make sure you understand how each step works before you go on to the next one. &lt;br /&gt;
&lt;br /&gt;
We also recommend reading the [[UnitTesting]] wiki page and follow the guide lines you find there. (ok the page is not finished, but it will hopefully be when it is needed).  It will make your life a lot easier later on when you have forgot how something is suppose to work. Try to adopt the samples you find in this article to a unit testing framework.&lt;br /&gt;
&lt;br /&gt;
== What is an array ==&lt;br /&gt;
An array is an identifier containing elements or variables (if you like), referenced by the identifier and an index.  Now we could have said a variable containing variables referenced by the variable and an index but I think that makes even less sense to most of us.&lt;br /&gt;
&lt;br /&gt;
This sounds complex. So, why should you learn about arrays? The short answer is that data structures are fundamental to programming.&lt;br /&gt;
&lt;br /&gt;
== Declaring Arrays in AutoIt ==&lt;br /&gt;
You declare an array in the same manner as you would declare any variable in AutoIt. But when you know it is an array, you add information on how many elements you want to have in the array. This information is provided by adding brackets after the identifier and a number indicating how many elements you want the array to hold. &lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Global $arr[4] ; Will make space for 4 elements.&lt;br /&gt;
 Local  $arr[1] ; Will make space for 1 element.&lt;br /&gt;
 ;NOTE! Avoid using Dim.  Use Global or Local instead.&lt;br /&gt;
 Dim    $arr[3] ; Will make space for 3 elements. &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Making space for 1 element may seem ridiculous, but further down the road we shall see how we can have arrays grow and shrink.  So when we declare an array with 1 element, it is usually just a place holder. &lt;br /&gt;
&lt;br /&gt;
In AutoIt, you can also declare an array as a normal variable and later get an array assigned to it from a function.  Note about the &amp;quot;from a function&amp;quot; part: this can refer to a user-defined function or an AutoIt internal built-in function.  The point is, a variable does not need to hold an array before the array is assigned to it.&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $arr = StringSplit(&amp;quot;This is my string. I want to split it in sentences.&amp;quot;, &amp;quot;.&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now to make really certain we have an array from StringSplit, we should check it with the IsArray($variable) built-in function.&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 If IsArray($arr) Then &lt;br /&gt;
     ; DO work on the array&lt;br /&gt;
 EndIf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Assigning Data to Array Elements ==&lt;br /&gt;
When we declare the array we make some room in memory for future data.  We want to assign some data to the items in the array.  Now here is the catch. The array always starts at index 0.  So, the first element in the array will be accessed by 0, the second element in the array is accessed at by 1 and so on.&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $arr[3] ; Make room for three elements&lt;br /&gt;
 ;Assign some data&lt;br /&gt;
 $arr[0]=&amp;quot;Element 1&amp;quot;&lt;br /&gt;
 $arr[1]=&amp;quot;Element 2&amp;quot;&lt;br /&gt;
 $arr[2]=&amp;quot;Element 3&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also assign all the data in one smack like this:&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $arr[3] = [&amp;quot;element 1&amp;quot;, &amp;quot;element 2&amp;quot;, &amp;quot;element 3&amp;quot;]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This 0-based indexing is quite common in most computer languages, but it can be a source of headaches to programmers until it becomes second nature to them.  For example, every time you want to loop through a range of elements and the range includes the last element, you have to subtract one from the number of items your array is holding, to get the index of the last item. I.E.,  An array with 3 elements has a last index of 2.&lt;br /&gt;
&lt;br /&gt;
So if you don&#039;t take 0-based indexing into consideration in your code, you may ask for something outside the memory area set aside for the array. When you do, you get an error message (&amp;lt;font color=&amp;quot;red&amp;quot;&amp;gt;Array variable has incorrect number of subscripts or subscript dimension range exceeded&amp;lt;/font&amp;gt;) and your script will cease execution.&lt;br /&gt;
&lt;br /&gt;
== Accessing Data in Arrays ==&lt;br /&gt;
Let&#039;s walk all elements in the previous sample:&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $arr[3] = [&amp;quot;element 1&amp;quot;, &amp;quot;element 2&amp;quot;, &amp;quot;element 3&amp;quot;] &lt;br /&gt;
 For $i = 0 to 3 - 1 ; We have an array with three elements but the last index is two.&lt;br /&gt;
     ConsoleWrite($arr[$i] &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Determine array size with UBound ===&lt;br /&gt;
The &amp;quot;3 - 1&amp;quot; construct used in the last sample looked strange.  It is not a good idea to hard-code size like that. So lets improve our sample a little. &lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax = 3&lt;br /&gt;
 Local $arr[$iMax] = [&amp;quot;Element 1&amp;quot;, &amp;quot;Element 2&amp;quot;, &amp;quot;Element 3&amp;quot;]&lt;br /&gt;
 For $i = 0 to $iMax - 1&lt;br /&gt;
     ConsoleWrite($arr[$i] &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now that&#039;s a bit cleaner. It&#039;s also a lot easier to increase or decrease the size of the array. &amp;lt;br&amp;gt;&lt;br /&gt;
But say you don&#039;t know the size of the array upfront because it may come in a variable size when created dynamically.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
Local $iMax &lt;br /&gt;
Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; &lt;br /&gt;
; The string in data will be split into an array everywhere | is encountered &lt;br /&gt;
Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) &lt;br /&gt;
If IsArray($arr) Then&lt;br /&gt;
     $iMax = UBound($arr); get array size&lt;br /&gt;
     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)&lt;br /&gt;
     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error&lt;br /&gt;
         ConsoleWrite($arr[$i] &amp;amp; @LF)&lt;br /&gt;
     Next&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When you run the above code you will see that $iMax is 4 and not 3 as you might have expected. The reason for this is that the developer of the StringSplit() function thought it was a good idea to use the first item (item 0) to keep a count of valid items in the array. This makes sense in many situations as you now have an array containing data with an index starting at 1. So our sample code can now be rewritten like this.&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax&lt;br /&gt;
 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot;&lt;br /&gt;
 ; The string in data will be split into an array everywhere | is encountered&lt;br /&gt;
 Local $arr = StringSplit($data, &amp;quot;|&amp;quot;)  &lt;br /&gt;
 If IsArray($arr) Then &lt;br /&gt;
     For $i = 1 to $arr[0]&lt;br /&gt;
         ConsoleWrite($arr[$i] &amp;amp; @LF)&lt;br /&gt;
     Next&lt;br /&gt;
 EndIf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
There is another good reason for keeping the count in $arr[0]. When you start to use arrays extensively, you will encounter situations where you have to create an array without knowing how many of the elements you will use. Resizing the array is a relatively expensive operation (in CPU cycles) in most languages.&lt;br /&gt;
&lt;br /&gt;
Now consider our example if our initial array has reserved space for 10 items but we end up only using 3. In this case iterating the array using UBound will force us to check for empty elements. While iterating with $arr[0] needs no other change than maintaining the correct count in $arr[0].&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=10&lt;br /&gt;
 ;NOTE: We have added the count in the first element&lt;br /&gt;
 Local $arr[$iMax] = [3, &amp;quot;Element 1&amp;quot;, &amp;quot;Element 2&amp;quot;, &amp;quot;Element 3&amp;quot;]&lt;br /&gt;
 ;NOTE: We use the count in $arr[0] to indicate the last item and we start from index=1&lt;br /&gt;
 For $i = 1 to $arr[0]&lt;br /&gt;
     ConsoleWrite($arr[$i] &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Changing array sizes with ReDim ==&lt;br /&gt;
As arrays are critical to algorithm implementations, and in AutoIt even more so as there is no other means of grouping data, we have to understand how to let it grow and shrink. This is where the keyword ReDim comes into the picture.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make an example. We want our array to hold data lines but we don&#039;t know how many items we need. We make a guess, in this case 5. Now, we use that array to hold data we get from a loop with a random number of iterations. If the array is too small it should automatically be increased. Before we dump the array to output, we should adjust it to the exact size it is supposed to be.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $iMax=5&lt;br /&gt;
 ;NOTE: We have added the count in the first element&lt;br /&gt;
 Local $arr[$iMax] = [0] ;Initiate the array and place a counter in the first element.&lt;br /&gt;
 ;Generate a random number between 0 and 20&lt;br /&gt;
 Local $iRandom = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $iRandom&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then&lt;br /&gt;
         ; Resize the array when $i is equal to the element count in the array to prevent subscript error&lt;br /&gt;
         ReDim $arr[$arr[0] + $iMax]&lt;br /&gt;
     EndIf&lt;br /&gt;
     $arr[$i] = &amp;quot;Item &amp;quot; &amp;amp; $i; safely add data to new index element&lt;br /&gt;
     $arr[0] = $i; update the index count for future reference&lt;br /&gt;
 Next&lt;br /&gt;
 ;Adjust the array size. This time it is probably downward to the size of&lt;br /&gt;
 ;$arr[0] + 1 (remember the first item is $arr[0])&lt;br /&gt;
 ReDim $arr[$arr[0]+1] &lt;br /&gt;
 ;Now dump the results&lt;br /&gt;
 For $i = 1 to $arr[0]&lt;br /&gt;
     ConsoleWrite(&amp;quot;$arr[&amp;quot; &amp;amp; $i &amp;amp; &amp;quot;]:=&amp;quot; &amp;amp; $arr[$i] &amp;amp;  @LF)&lt;br /&gt;
 Next&lt;br /&gt;
 ; Visually check that the values are sound&lt;br /&gt;
ConsoleWrite( &amp;quot;Ubound($arr):=&amp;quot; &amp;amp; UBound($arr) &amp;amp; &amp;quot;, $arr[0]:=&amp;quot; &amp;amp; $arr[0] &amp;amp; &amp;quot;, $iRandom:=&amp;quot; &amp;amp; $iRandom &amp;amp; @LF)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Note how the array now has first been adjusted to a multiple of $iMax and in the last part adjusted down to a size matching the data items.&lt;br /&gt;
&lt;br /&gt;
== Multi dimensional arrays ==&lt;br /&gt;
Now what is a good explanation of an multi-dimensional array?&lt;br /&gt;
It could be a table where you access one item in the table at a time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local  $arr[3][3] = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]&lt;br /&gt;
 For $i = 0 to UBound( $arr, 1) - 1&lt;br /&gt;
   For $j = 0 to UBound($arr, 2) - 1&lt;br /&gt;
	  ConsoleWrite(&amp;quot;$arr[&amp;quot; &amp;amp; $i &amp;amp; &amp;quot;][&amp;quot; &amp;amp; $j &amp;amp; &amp;quot;]:=&amp;quot; &amp;amp; $arr[$i][$j] &amp;amp; @LF)&lt;br /&gt;
   Next &lt;br /&gt;
   ConsoleWrite(@LF)&lt;br /&gt;
 Next &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can add a number of dimensions not to exceed 64 as stated in the help file section &amp;quot;AutoIt&amp;gt;Appendix&amp;gt;AutoIt3 limits/Defaults&amp;quot;. &lt;br /&gt;
Drop me a note if you encounter any circumstances where it might be simpler to add dimensions rather than using other techniques.&lt;br /&gt;
&lt;br /&gt;
Here is a 4 dimensional sample. You tell me how that initializer is for readability.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt; ; NOTE: The following is supposed to be all on one line&lt;br /&gt;
 ; but we use the &amp;quot;_&amp;quot; character to split it into multiple lines for readability &lt;br /&gt;
 Local $arr[3][3][3][3] = [ _         &lt;br /&gt;
         [[[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]]], _&lt;br /&gt;
         [[[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]]], _&lt;br /&gt;
         [[[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]], [[1, 2, 3],[2, 3, 4],[3, 4, 5]]] _&lt;br /&gt;
     ] &lt;br /&gt;
&lt;br /&gt;
 For $i = 0 To UBound($arr, 1) - 1&lt;br /&gt;
     For $j = 0 To UBound($arr, 2) - 1&lt;br /&gt;
         For $k = 0 To UBound($arr, 3) - 1&lt;br /&gt;
             For $l = 0 To UBound($arr, 4) - 1&lt;br /&gt;
                 ConsoleWrite(&amp;quot;$arr[&amp;quot; &amp;amp; $i &amp;amp; &amp;quot;][&amp;quot; &amp;amp; $j &amp;amp; &amp;quot;][&amp;quot; &amp;amp; $k &amp;amp; &amp;quot;][&amp;quot; &amp;amp; $l &amp;amp; &amp;quot;]:=&amp;quot; &amp;amp; $arr[$i][$j][$k][$l] &amp;amp; @LF)&lt;br /&gt;
             Next&lt;br /&gt;
         Next&lt;br /&gt;
     Next&lt;br /&gt;
     ConsoleWrite(@LF)&lt;br /&gt;
 Next&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Arrays in arrays ==&lt;br /&gt;
You may save an array in an array element (item). The thing is, there is no way to directly access that array stored in the element. You have to go through a variable to get access to the embedded array which may make your code overly complicated and difficult to debug.&lt;br /&gt;
&lt;br /&gt;
Remember that there may be issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, try not to embed arrays within arrays unless you absolutely need to and are prepared to do rigorous testing to make sure your code will always work as expected.&lt;br /&gt;
&lt;br /&gt;
That said, here is an example.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;Local $arr[3]&lt;br /&gt;
Local $a1[3] = [2, &amp;quot;a1-1&amp;quot;,&amp;quot;a1-2&amp;quot;]&lt;br /&gt;
Local $a2[3] = [2, &amp;quot;a2-1&amp;quot;,&amp;quot;a2-2&amp;quot;]&lt;br /&gt;
$arr[1] = $a1&lt;br /&gt;
$arr[2] = $a2&lt;br /&gt;
$arr[0] = 2&lt;br /&gt;
Local $dumy&lt;br /&gt;
&lt;br /&gt;
For $i = 1 to $arr[0]&lt;br /&gt;
    $dumy = $arr[$i]&lt;br /&gt;
    If IsArray($dumy) Then&lt;br /&gt;
        For $j = 1 to $dumy[0]&lt;br /&gt;
            ConsoleWrite(&amp;quot;$i:=&amp;quot; &amp;amp; $i &amp;amp; &amp;quot;, $dumy[&amp;quot; &amp;amp; $j &amp;amp; &amp;quot;]:=&amp;quot; &amp;amp; $dumy[$j] &amp;amp; @LF)&lt;br /&gt;
        Next&lt;br /&gt;
    Else&lt;br /&gt;
        ConsoleWrite(&amp;quot;!&amp;gt;Oops!, What happened? Expected an array!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
    EndIf&lt;br /&gt;
Next&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Passing arrays to a function ==&lt;br /&gt;
There is no hocus pocus about this. Only a few rules.&lt;br /&gt;
&lt;br /&gt;
* You can not declare the variable to hold the array in the function declaration as an array. So, users could pass on a variable. So you have to check that the variable holds an array before you do array specific operations on it.&lt;br /&gt;
* You don&#039;t have to, but you should, specify the variable to hold the array as ByRef.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, during the tutorial you have probably noticed that there is a lot of code that is equal in each sample. I&#039;m especially thinking about the code we have used to output the array content. Let&#039;s make life easier and create a debug function&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func dbgArray(ByRef $arr, $msg=&amp;quot;&amp;quot;)&lt;br /&gt;
     If $msg &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then &lt;br /&gt;
         ConsoleWrite(&amp;quot;*** &amp;quot; &amp;amp; $msg &amp;amp; &amp;quot; ***&amp;quot; &amp;amp; @LF)&lt;br /&gt;
     EndIf&lt;br /&gt;
     Local $i&lt;br /&gt;
     For $i = 0 to UBound($arr) - 1&lt;br /&gt;
        ConsoleWrite(&amp;quot;$arr[&amp;quot; &amp;amp; $i &amp;amp; &amp;quot;]:=&amp;quot; &amp;amp; $arr[$i] &amp;amp;  @LF)&lt;br /&gt;
     Next&lt;br /&gt;
     ConsoleWrite( &amp;quot;Ubound($arr)=:=&amp;quot; &amp;amp; UBound($arr) &amp;amp; &amp;quot;, $arr[0]:=&amp;quot; &amp;amp; $arr[0] &amp;amp; @LF)   &lt;br /&gt;
 EndFunc &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And let&#039;s make a little function to fill our arrays with something. Note how the ArrayFiller makes sure it works on an array.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func ArrayFiller(ByRef $arr)&lt;br /&gt;
     If IsArray($arr) Then &lt;br /&gt;
         ReDim $arr[3] ;Notice we might discard content in this operation&lt;br /&gt;
     Else&lt;br /&gt;
         Local $foo[3]&lt;br /&gt;
         $arr = $foo&lt;br /&gt;
     EndIf &lt;br /&gt;
     ;Fill the array&lt;br /&gt;
     $arr[0] = 2&lt;br /&gt;
     $arr[1] = &amp;quot;Fill 1&amp;quot;&lt;br /&gt;
     $arr[2] = &amp;quot;Fill 2&amp;quot;&lt;br /&gt;
 EndFunc &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
And finally some code using the new functions&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
   Local $arr1[1]&lt;br /&gt;
   ArrayFiller($arr1)&lt;br /&gt;
   dbgArray($arr1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is a test on what happens when we pass a regular variable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
   Local $arr2&lt;br /&gt;
   ArrayFiller($arr2)&lt;br /&gt;
   dbgArray($arr2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Passing arrays from a function ==&lt;br /&gt;
As you could observe, in the previous samples, an array will be passed back and forth with the ByRef keyword infront of the variable holding the array in the function declaration.&lt;br /&gt;
&lt;br /&gt;
We could also have used the Return keyword in a function.&lt;br /&gt;
Lets re-work the ArrayFiller function to do this rather than using a variable ByRef.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func ArrayFiller2()&lt;br /&gt;
   Local $arr = [3, &amp;quot;Fill 1&amp;quot;, &amp;quot;Fill 2&amp;quot;]&lt;br /&gt;
   Return $arr&lt;br /&gt;
 EndFunc &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And now we can use the function like this&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $foo = ArrayFiller2()&lt;br /&gt;
 dbgArray($foo)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Forum FAQ about arrays ==&lt;br /&gt;
Feel free to add questions and answers you have encountered in the forum.&lt;br /&gt;
&lt;br /&gt;
===Accessing Arrays===&lt;br /&gt;
Obviously one can assign arrays to variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$NewArray = $OldArray&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
One can also assign single array elements:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array[1] = &amp;quot;Element 1&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content = $Array[1]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Comparing Arrays===&lt;br /&gt;
&#039;&#039;&#039;You can not, however, compare complete arrays:&#039;&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $Array1[3] = [1, 2, 3]&lt;br /&gt;
Local $Array2[3] = [1, 2, 3]&lt;br /&gt;
Local $Array3[4] = [1, 2, 3, 4]&lt;br /&gt;
&lt;br /&gt;
If $Array1 == $Array2 Then ConsoleWrite(&amp;quot;1.) $Array1 is equal to $Array2! which might be correct in some sense.&amp;quot; &amp;amp; @LF); while they contain the same data, the comparison does not work.&lt;br /&gt;
If $Array1 == $Array3 Then ConsoleWrite(&amp;quot;2.) $Array1 is equal to $Array3! which is incorrect.&amp;quot; &amp;amp; @LF); even though they&#039;re different in size, it&#039;s incorrectly determined that they&#039;re equal.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I have the impression that such comparisons compare the memory address of the arrays instead of the array elements values. And the addresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have to instead, compare all elements one after the other. It might be a good idea to first compare array sizes if that can vary for both the compared arrays!&lt;br /&gt;
&lt;br /&gt;
===Array UDF: array.au3===&lt;br /&gt;
AutoIt features a large list of User-Defined Functions (UDF), among is a module supplying extra array functions. You can find a reference on those functions in AutoIt&#039;s Help file as the last main chapter named &#039;User Defined Functions Reference&#039;.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;/div&gt;</summary>
		<author><name>DoubleMcLovin</name></author>
	</entry>
</feed>