<?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=FlutterShy</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=FlutterShy"/>
	<link rel="alternate" type="text/html" href="https://www.autoitscript.com/wiki/Special:Contributions/FlutterShy"/>
	<updated>2026-05-16T18:47:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=11488</id>
		<title>User Defined Functions</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=11488"/>
		<updated>2012-12-13T16:30:17Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Internet protocol suite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:UDF]]&lt;br /&gt;
This page is a listing of libraries of user defined functions. These libraries have been written to allow easy integration into your own script and are a very valuable resource for any programmer.&lt;br /&gt;
&lt;br /&gt;
== Automation ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=87956 Java UDF] - Creates an access bridge between your application and a Java application. Allowing you to automate some Java applications.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=86574 SAP] - SAP business management automation.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=42776 PDFCreator] - Automation of PDFCreator allows you to create and manipulate PDF files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=91018 WiFi] - Low level control over your wireless LAN &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106163 Active Directory] - Extensive library to control and manipulate the Windows active directory. Link to the [[Active_Directory_UDF_-_General|documentation]] pages. &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=28436 Windows Events] - Create your own Windows events.&lt;br /&gt;
&lt;br /&gt;
===Browsers===&lt;br /&gt;
* Internet Explorer - Everything about Internet explorer can be automated with the IE library supplied with a standard AutoIt install.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95595 FireFox] - A little less support for automation than IE, but still very good.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=61090 Opera] - The same as above for Opera. Automate the most common tasks in Opera with the Opera UDF.&lt;br /&gt;
&lt;br /&gt;
===Microsoft Office Automation===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32144 Microsoft Office Access] - Automation of Access.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=34302 Microsoft Office Excel] - Large automation library for Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/135312-excelchart-udf Microsoft Office Excel] - Creating charts using Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126305-outlookex-udf/ Microsoft Office Outlook] - Extended Outlook UDF. Link to the [[OutlookEX_UDF_-_General|documentation]] pages.&lt;br /&gt;
* Microsoft Office Word UDF - A way to automate Office Word is included with AutoIt.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=45842 Serial port (COM port)] - Requires my comMG.dll (included)&lt;br /&gt;
&lt;br /&gt;
== Information gathering ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=29404 Computer information] - A general purpose library to get various details about a Windows machine.&lt;br /&gt;
&lt;br /&gt;
== Databases and web connections ==&lt;br /&gt;
* FTP - A FTP library is now included with the AutoIt libraries.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=17099 SQLite] - &amp;quot;SQLite is a library that implements a self-contained, embeddable, zero-configuration SQL database engine&amp;quot;&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=19848 XML DOM Wrapper] - Supports CRUD operations on XML. Including XSL and XPath.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20814 MySQL] - MySQL relational database management system UDF.&lt;br /&gt;
&lt;br /&gt;
== Internet protocol suite ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/84133-winhttp-functions/ WinHTTP] - Enables scripts to access the HTTP protocol for creating GET and POST requests and submitting them with conforming standards, cookies not supported.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/77503-wininetau3-ftphttphttpsgopher/ WinInet] - Enables scripts to access standard Internet protocols, such as FTP, Gopher and HTTP. Also supports creating GET and POST requests and submitting them with conforming standards, cookies supported.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=22838 POP3] - POP3 library for retrieving email messages. Not compatible with Gmail because it uses SSL.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=64051 POP3 SSL] - A POP3 library that&#039;s compatible with Gmail. It uses an external executable that must be supplied with your script.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=43515 IRC] - A lightweight library for communicating with IRC servers.&lt;br /&gt;
&lt;br /&gt;
== Data compression ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=116565 zip] - Create ZIP files and unpack ZIP files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=85094 7z, zip, gzip, bzip2, tar] - More extensive library than the one above. Uses a external DLL that must be provided with the script.&lt;br /&gt;
&lt;br /&gt;
== Encryption and hash ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=76976 MD5,SHA1,CRC32,RC4,BASE64,XXTEA] - Several encryption and hash functions.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=78745 AES Rijndael] - Very fast AES UDF. Support ECB/CBC/CFB/OFB block cipher mode.&lt;br /&gt;
&lt;br /&gt;
== Media ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=94834 Simple DirectMedia Layer UDF] - Adds support for joysticks, CDs, 2D graphics, timers. See [http://www.libsdl.org/ SDL website] for more information.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95357 FreeImage library] - Various operations on images, such as rotate, resize, flip.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=51054 Printer controller] - Print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images.&lt;br /&gt;
&lt;br /&gt;
===Sound===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83481 BASS Function Library] - Sound and Music via wrappers for Bass, BassEnc, Bass FX, BassSFX, BassAsio and BassCd DLLs&lt;br /&gt;
&lt;br /&gt;
===3D graphics===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=70506 IrrLicht] - A 3D graphics engine suitable for creating games.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=113881 au3Irrlicht2] - Another UDF bringing Irrlicht and au3 together. Historically some kind of a follower of the UDF above, technically with a complete different approach.&lt;br /&gt;
&lt;br /&gt;
== GUI Additions ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32494 XSkin] - A large library that allows skinning of your GUI and to apply custom skins.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/132864-uskinlibraryau3-udf-skin-with-dll-free-no-ads-and-fully-functional/ Uskin] - A library that allows a user to skin their application GUI using the Windows &#039;&#039;.MSstyles&#039;&#039; files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20967 Modern tray menu] - Allows the creation of modern, fancy GUI and tray menus with icons.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=71811 SetOnEvent] - Provides an easy way for an event to call functions with parameters.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/119505-guiframe-udf-melba23-version/ GUIFrame] - Divide a GUI into adjustable frames.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy/ Easy Scrollbars] - Easily create scrollable sections in your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105582 GUICtrlOnChangeRegister] - Call a function when an edits content is changed.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96258-contexthelp-au3/ ContextHelp.au3] - Management of context help ([http://www.autoitscript.com/forum/topic/72152-contexthelp/ original])&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/117909-guiextender-new-version-171110/ GUIExtender] - Expand and contract sections of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/109096-extended-message-box-new-version-3-dec-10/ ExtMsgBox] - A very customisable replacement for MsgBox&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/108445-how-to-make-toast/ Toast] - Small message GUIs which pop out of the Systray&lt;br /&gt;
&lt;br /&gt;
=== Controls ===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=79412 Graph control UDF] - Easily create and show bar chart and line charts.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105682 GUICtrlCreateFinder] - Allows you to create a window finder control like the one seen in AutoIt Window Info.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=111438 GUIPager] - Create and control native pager controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=90598 Hotkey input control] - Hotkeys Input Control UDF Library (Non-native)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=107965 GUIHotkey] - UDF for using native hotkey controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/103904-info-bar-like-tickertape/page__view__findpost__p__735769 Marquees] - Make tickertape info bars&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96464-colorpicker-udf/ Colorpicker] - Create a button for the user to select a color.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126958-guisyslink-udf/ Syslink] - Provides a convenient way to embed hypertext links in a window&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/74649-progressbar-with-gdiplus/ Progressbar with GDIplus] - You even can use full textured images&lt;br /&gt;
&lt;br /&gt;
== Maths ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83091 Primes UDF] - Many functions dealing with prime number generation and calculations.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83529 Big number UDF] - Make calculations with extremely large numbers that AutoIt normally is not able to support.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=81189 Number base conversion] - From, to and between positive bases less than 63 (decimals supported)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106551 Decimal To fraction] - Converts any decimal number to a fraction. Example: 1.2 to 6/5&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=82722 Trigonometry math functions] - _ATan2(), _Cosh(), _Frexp(), _Hypot(), _Ldexp(), _Logb(), _Sinh(), _Tanh()&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=108803 Polynomials] - Functions for using polynomials.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=117156 NumToWord] - Convert numerals to a human readable string.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=98160 Root function] - Working out real roots of numbers.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/102686-advanced-rounding/ Advanced rounding] - Support for different measures of accuracy and 8 ways to resolve tie breaks.&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/90492-hotkey-au3/ Hotkey.au3] - Management of Hotkeys UDF, with several advantages over HotkeySet().&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/97826-animateau3-updated/ Animated tray icons] - Make animated tray icons easily.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/101733-prevent-dotted-focus-lines-on-controls/ NoFocusLines] - Remove the dotted focus lines from buttons, sliders, radios and checkboxes which spoil the look of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/114034-stringsize-m23/ StringSize] - Automatically size controls to fit the text you want to put in them&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/ JSON] - RFC4627 compliant JSON encode/decode&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=11299</id>
		<title>User Defined Functions</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=11299"/>
		<updated>2012-11-13T16:24:43Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* GUI Additions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is a listing of libraries of user defined functions. These libraries have been written to allow easy integration into your own script and are a very valuable resource for any programmer.&lt;br /&gt;
&lt;br /&gt;
== Automation ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=87956 Java UDF] - Creates an access bridge between your application and a Java application. Allowing you to automate some Java applications.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=86574 SAP] - SAP business management automation.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=42776 PDFCreator] - Automation of PDFCreator allows you to create and manipulate PDF files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=91018 WiFi] - Low level control over your wireless LAN &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106163 Active Directory] - Extensive library to control and manipulate the Windows active directory. Link to the [[Active_Directory_UDF_-_General|documentation]] pages. &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=28436 Windows Events] - Create your own Windows events.&lt;br /&gt;
&lt;br /&gt;
===Browsers===&lt;br /&gt;
* Internet Explorer - Everything about Internet explorer can be automated with the IE library supplied with a standard AutoIt install.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95595 FireFox] - A little less support for automation than IE, but still very good.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=61090 Opera] - The same as above for Opera. Automate the most common tasks in Opera with the Opera UDF.&lt;br /&gt;
&lt;br /&gt;
===Microsoft Office Automation===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32144 Microsoft Office Access] - Automation of Access.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=34302 Microsoft Office Excel] - Large automation library for Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/135312-excelchart-udf Microsoft Office Excel] - Creating charts using Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126305-outlookex-udf/ Microsoft Office Outlook] - Extended Outlook UDF. Link to the [[OutlookEX_UDF_-_General|documentation]] pages.&lt;br /&gt;
* Microsoft Office Word UDF - A way to automate Office Word is included with AutoIt.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=45842 Serial port (COM port)] - Requires my comMG.dll (included)&lt;br /&gt;
&lt;br /&gt;
== Information gathering ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=29404 Computer information] - A general purpose library to get various details about a Windows machine.&lt;br /&gt;
&lt;br /&gt;
== Databases and web connections ==&lt;br /&gt;
* FTP - A FTP library is now included with the AutoIt libraries.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=17099 SQLite] - &amp;quot;SQLite is a library that implements a self-contained, embeddable, zero-configuration SQL database engine&amp;quot;&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=19848 XML DOM Wrapper] - Supports CRUD operations on XML. Including XSL and XPath.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20814 MySQL] - MySQL relational database management system UDF.&lt;br /&gt;
&lt;br /&gt;
== Internet protocol suite ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/84133-winhttp-functions/ HTTP] - For creating GET and POST requests and submitting them with conforming standards.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=22838 POP3] - POP3 library for retrieving email messages. Not compatible with Gmail because it uses SSL.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=64051 POP3 SSL] - A POP3 library that&#039;s compatible with Gmail. It uses an external executable that must be supplied with your script.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=43515 IRC] - A lightweight library for communicating with IRC servers.&lt;br /&gt;
&lt;br /&gt;
== Data compression ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=116565 zip] - Create ZIP files and unpack ZIP files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=85094 7z, zip, gzip, bzip2, tar] - More extensive library than the one above. Uses a external DLL that must be provided with the script.&lt;br /&gt;
&lt;br /&gt;
== Encryption and hash ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=76976 MD5,SHA1,CRC32,RC4,BASE64,XXTEA] - Several encryption and hash functions.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=78745 AES Rijndael] - Very fast AES UDF. Support ECB/CBC/CFB/OFB block cipher mode.&lt;br /&gt;
&lt;br /&gt;
== Media ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=94834 Simple DirectMedia Layer UDF] - Adds support for joysticks, CDs, 2D graphics, timers. See [http://www.libsdl.org/ SDL website] for more information.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95357 FreeImage library] - Various operations on images, such as rotate, resize, flip.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=51054 Printer controller] - Print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images.&lt;br /&gt;
&lt;br /&gt;
===Sound===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83481 BASS Function Library] - Sound and Music via wrappers for Bass, BassEnc, Bass FX, BassSFX, BassAsio and BassCd DLLs&lt;br /&gt;
&lt;br /&gt;
===3D graphics===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=70506 IrrLicht] - A 3D graphics engine suitable for creating games.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=113881 au3Irrlicht2] - Another UDF bringing Irrlicht and au3 together. Historically some kind of a follower of the UDF above, technically with a complete different approach.&lt;br /&gt;
&lt;br /&gt;
== GUI Additions ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32494 XSkin] - A large library that allows skinning of your GUI and to apply custom skins.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/132864-uskinlibraryau3-udf-skin-with-dll-free-no-ads-and-fully-functional/ Uskin] - A library that allows a user to skin their application GUI using the Windows &#039;&#039;.MSstyles&#039;&#039; files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20967 Modern tray menu] - Allows the creation of modern, fancy GUI and tray menus with icons.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=71811 SetOnEvent] - Provides an easy way for an event to call functions with parameters.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/119505-guiframe-udf-melba23-version/ GUIFrame] - Divide a GUI into adjustable frames.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy/ Easy Scrollbars] - Easily create scrollable sections in your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105582 GUICtrlOnChangeRegister] - Call a function when an edits content is changed.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96258-contexthelp-au3/ ContextHelp.au3] - Management of context help ([http://www.autoitscript.com/forum/topic/72152-contexthelp/ original])&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/117909-guiextender-new-version-171110/ GUIExtender] - Expand and contract sections of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/109096-extended-message-box-new-version-3-dec-10/ ExtMsgBox] - A very customisable replacement for MsgBox&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/108445-how-to-make-toast/ Toast] - Small message GUIs which pop out of the Systray&lt;br /&gt;
&lt;br /&gt;
=== Controls ===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=79412 Graph control UDF] - Easily create and show bar chart and line charts.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105682 GUICtrlCreateFinder] - Allows you to create a window finder control like the one seen in AutoIt Window Info.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=111438 GUIPager] - Create and control native pager controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=90598 Hotkey input control] - Hotkeys Input Control UDF Library (Non-native)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=107965 GUIHotkey] - UDF for using native hotkey controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/103904-info-bar-like-tickertape/page__view__findpost__p__735769 Marquees] - Make tickertape info bars&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96464-colorpicker-udf/ Colorpicker] - Create a button for the user to select a color.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126958-guisyslink-udf/ Syslink] - Provides a convenient way to embed hypertext links in a window&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/74649-progressbar-with-gdiplus/ Progressbar with GDIplus] - You even can use full textured images&lt;br /&gt;
&lt;br /&gt;
== Maths ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83091 Primes UDF] - Many functions dealing with prime number generation and calculations.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83529 Big number UDF] - Make calculations with extremely large numbers that AutoIt normally is not able to support.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=81189 Number base conversion] - From, to and between positive bases less than 63 (decimals supported)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106551 Decimal To fraction] - Converts any decimal number to a fraction. Example: 1.2 to 6/5&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=82722 Trigonometry math functions] - _ATan2(), _Cosh(), _Frexp(), _Hypot(), _Ldexp(), _Logb(), _Sinh(), _Tanh()&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=108803 Polynomials] - Functions for using polynomials.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=117156 NumToWord] - Convert numerals to a human readable string.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=98160 Root function] - Working out real roots of numbers.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/102686-advanced-rounding/ Advanced rounding] - Support for different measures of accuracy and 8 ways to resolve tie breaks.&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/90492-hotkey-au3/ Hotkey.au3] - Management of Hotkeys UDF, with several advantages over HotkeySet().&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/97826-animateau3-updated/ Animated tray icons] - Make animated tray icons easily.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/101733-prevent-dotted-focus-lines-on-controls/ NoFocusLines] - Remove the dotted focus lines from buttons, sliders, radios and checkboxes which spoil the look of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/114034-stringsize-m23/ StringSize] - Automatically size controls to fit the text you want to put in them&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Talk:User_Defined_Functions&amp;diff=11298</id>
		<title>Talk:User Defined Functions</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Talk:User_Defined_Functions&amp;diff=11298"/>
		<updated>2012-11-13T16:19:44Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page should really be a spin-off from: http://www.autoitscript.com/forum/index.php?showtopic=19370&lt;br /&gt;
[[User:Manadar|Manadar]] 13:12, 27 May 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Migrated UDF List here ==&lt;br /&gt;
&lt;br /&gt;
The old page can still be seen here: http://www.autoitscript.com/w/index.php?title=UDF_List&amp;amp;action=edit&lt;br /&gt;
&lt;br /&gt;
== Changes to AutoIt wrappers ==&lt;br /&gt;
&lt;br /&gt;
Currently the old wrappers forum thread by valuator is locked and is being migrated to the wiki (link?). I have just removed the outdated link for now.&lt;br /&gt;
--[[User:Mat|Mat]] 19:28, 24 September 2012 (BST)&lt;br /&gt;
&lt;br /&gt;
== Internet protocol suite ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=64051 POP3 SSL] - A POP3 library that&#039;s compatible with Gmail. It uses an external executable that must be supplied with your script.&lt;br /&gt;
&lt;br /&gt;
Are we sure we should link this topic in here?&lt;br /&gt;
I&#039;ve looked through it and the &#039;&#039;user who made the topic never posted anything that works&#039;&#039;, they just explained how their script worked and &#039;&#039;never actually provided code...&#039;&#039;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11295</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11295"/>
		<updated>2012-11-13T11:53:58Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* SciTE4AutoIt3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SciTE4AutoIt3=&lt;br /&gt;
SciTE4AutoIt3 is a specialist editor package based on the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  SciTE has been set up to compile AutoIt scripts and has been extended with a multitude of Lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
SciTE4AutoIt3 provides:&lt;br /&gt;
* Syntax highlighting&lt;br /&gt;
* Calltips (also known as IntelliSense)&lt;br /&gt;
* Code AutoComplete&lt;br /&gt;
* Auto Indentation&lt;br /&gt;
* AutoIt Script help integration&lt;br /&gt;
* SciTE help integration&lt;br /&gt;
* Abbreviations&lt;br /&gt;
* Editing macros&lt;br /&gt;
* Debugging support&lt;br /&gt;
* Tools for AutoIt scripting&lt;br /&gt;
* A toolbar that enables easy access to an array of community created tools&lt;br /&gt;
* Various other features&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Keep in mind that SciTE4AutoIt3 is not an official package.  Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.&lt;br /&gt;
&lt;br /&gt;
=Syntax Highlighting=&lt;br /&gt;
[[File:Syntax_Highlight.png|457px|thumb|right|A demonstration of syntax highlighting using the default theme.]]&lt;br /&gt;
SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting.  Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments, etc.  This allows one to differentiate the various code elements at a glance without having to specifically read everything.  To load a custom theme a user may press [Ctrl] + [1] to bring up &#039;&#039;SciTEConfig&#039;&#039;.  The options are located under the &#039;&#039;Color Settings&#039;&#039; tab.&lt;br /&gt;
&lt;br /&gt;
Some options that are available for customization include:&lt;br /&gt;
* White Space&lt;br /&gt;
* Comment Line&lt;br /&gt;
* Comment Block&lt;br /&gt;
* Number&lt;br /&gt;
* Function&lt;br /&gt;
* Keyword&lt;br /&gt;
* Macro&lt;br /&gt;
* String&lt;br /&gt;
&lt;br /&gt;
=Quick Tips=&lt;br /&gt;
To access the helpfile the user may press [Alt] + [F1]. &lt;br /&gt;
To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the [F1] key to bring up the help file on the relevant page.&lt;br /&gt;
&lt;br /&gt;
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation. &#039;&#039;It&#039;s recommended that you read it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For anyone not familiar with SciTE, here are a few tips and tricks to help you easily modify the installation to suit your needs. For any &amp;quot;truly&amp;quot; advanced info, you should visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].&lt;br /&gt;
&lt;br /&gt;
With the information below, you will be doing some minor editing to SciTE&#039;s configuration files.&lt;br /&gt;
It is imperative that you know the hierarchy of SciTE&#039;s configuration files. The main files we will be dealing with here are listed below.&lt;br /&gt;
&lt;br /&gt;
Remember there are four properties files used:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;SciTE.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEDirectory.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEUser.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEGlobal.properties&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTE.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEDirectory.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Directory properties file which may be present in the same or in a parent directory as the file being edited. This file overrides all properties setting of the files below, but not the local properties settings aka &#039;&#039;SciTE.properties&#039;&#039;. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEUser.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;User properties file, this files settings override only the Global properties settings aka &#039;&#039;SciTEGlobal.properties&#039;&#039;. This file is found under the current logged on users profile directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEGlobal.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;All settings in this file can be overridden by any of the above files. Typically you shouldn&#039;t mess with this file and use any of the above methods to implement a setting change. This file can be found in SciTE&#039;s installation directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you have any trouble finding any of the previously mentioned files then I recommend that you do &#039;&#039;not&#039;&#039; continue further.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Inline Errors==&lt;br /&gt;
[[File:InlineError.JPG‎‎|234px|thumb|right|Intentional error prone code used to display the &amp;quot;Inline Error&amp;quot; feature.]]&lt;br /&gt;
In the latest version of SciTE, there exists a new feature called &amp;quot;Inline Errors&amp;quot;, some users find them annoying. Inline Error marks are error messages that will appear in the source code within the Scintilla window. While helpful, some users prefer to disable this feature often for unknown reasons.&lt;br /&gt;
You can quickly disable/enable them using the &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Open the SciTE user properties file in a text editor and add the following code to the file.&lt;br /&gt;
&lt;br /&gt;
To disable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To enable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Selection Highlighting==&lt;br /&gt;
In the latest SciTE4AutoIt3, there is a new feature which highlights other instances of the currently highlighted word or string. Due to the colors, sometimes it&#039;s hard to tell the selection apart.&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like, you can do either of two things using the &#039;&#039;SciTEUser.properties&#039;&#039;.&lt;br /&gt;
# Disable it&lt;br /&gt;
# Change the color scheme&lt;br /&gt;
&lt;br /&gt;
To disable it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To re-enable it, just delete it and save.&lt;br /&gt;
&lt;br /&gt;
To change the color scheme, add the following to your SciTEUser.properties file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word.colour=#000040&lt;br /&gt;
selection.alpha=50&lt;br /&gt;
selection.back=#F025A8&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The user should try adjusting the &#039;&#039;#COLOR&#039;&#039; values to come to a preferred color.&lt;br /&gt;
&lt;br /&gt;
==More Language Highlighting Options==&lt;br /&gt;
In the SciTEUser.properties file, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Language Highlighting Options&lt;br /&gt;
menu.language=\&lt;br /&gt;
#FreeBasic|bas||\&lt;br /&gt;
Text|txt|Shift+F11|\&lt;br /&gt;
#Ada|ads||\&lt;br /&gt;
AutoIt3|au3|Shift+F12|\&lt;br /&gt;
#Apache Confi&amp;amp;g|conf||\&lt;br /&gt;
#Assembler|asm||\&lt;br /&gt;
#ASN.1|asn1||\&lt;br /&gt;
#Avenue|ave||\&lt;br /&gt;
#Baan|bc||\&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
#Bullant|ant||\&lt;br /&gt;
#&amp;amp;C / C++|cpp||\&lt;br /&gt;
#CMake|cmake||\&lt;br /&gt;
#C&amp;amp;#|cs||\&lt;br /&gt;
#COBOL|cob||\&lt;br /&gt;
#Csound|orc||\&lt;br /&gt;
#CSS|css||\&lt;br /&gt;
#D|d||\&lt;br /&gt;
#&amp;amp;Difference|diff||\&lt;br /&gt;
#&amp;amp;Eiffel|e||\&lt;br /&gt;
#Erlang|erl||\&lt;br /&gt;
#&amp;amp;Errorlist|err||\&lt;br /&gt;
#FlagShip|prg||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#Gap|g||\&lt;br /&gt;
#Haskell|hs||\&lt;br /&gt;
#H&amp;amp;ypertext|html|$(keyHTML)|\&lt;br /&gt;
#&amp;amp;InnoSetup|iss||\&lt;br /&gt;
#&amp;amp;Java|java||\&lt;br /&gt;
#Java&amp;amp;Script|js||\&lt;br /&gt;
#&amp;amp;Kix|kix||\&lt;br /&gt;
#Lisp|lisp||\&lt;br /&gt;
#Lot|lot||\&lt;br /&gt;
#Lout|lt||\&lt;br /&gt;
#Lu&amp;amp;a|lua||\&lt;br /&gt;
#Matlab|m.matlab||\&lt;br /&gt;
#&amp;amp;Makefile|mak||\&lt;br /&gt;
#MetaPost|mp||\&lt;br /&gt;
#MMIXAL|mms||\&lt;br /&gt;
#Modula-3|m3||\&lt;br /&gt;
#&amp;amp;nnCron crontab|tab||\&lt;br /&gt;
#NSIS|nsis||\&lt;br /&gt;
#Objective Caml|ml||\&lt;br /&gt;
#Octave|m.octave||\&lt;br /&gt;
#Opal|impl||\&lt;br /&gt;
#Pascal|pas||\&lt;br /&gt;
#Pe&amp;amp;rl|pl||\&lt;br /&gt;
#P&amp;amp;HP|php||\&lt;br /&gt;
#P&amp;amp;LSQL|spec||\&lt;br /&gt;
#P&amp;amp;ostScript|ps||\&lt;br /&gt;
#P&amp;amp;OV-Ray SDL|pov||\&lt;br /&gt;
#PowerShell|ps1||\&lt;br /&gt;
#PowerPro|powerpro||\&lt;br /&gt;
#&amp;amp;Properties|properties||\&lt;br /&gt;
#Pytho&amp;amp;n|py||\&lt;br /&gt;
#R|R||\&lt;br /&gt;
#Reso&amp;amp;urce|rc||\&lt;br /&gt;
#Ruby|rb||\&lt;br /&gt;
#Shell|sh||\&lt;br /&gt;
#S&amp;amp;QL|sql||\&lt;br /&gt;
#Specman|e||\&lt;br /&gt;
#&amp;amp;TCL|tcl||\&lt;br /&gt;
#TeX|tex||\&lt;br /&gt;
#&amp;amp;txt2tags|t2t||\&lt;br /&gt;
#&amp;amp;VB|vb||\&lt;br /&gt;
#VBScr&amp;amp;ipt|vbs||\&lt;br /&gt;
#Verilog|v||\&lt;br /&gt;
#VHDL|vhd||\&lt;br /&gt;
#&amp;amp;XML|xml||\&lt;br /&gt;
#&amp;amp;YAML|yaml||&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For whatever language you wish to have an option appear under the &#039;&#039;Language&#039;&#039; menu option, uncomment the language.  Say you want to SciTE to give you the option to highlight batch script code, change the following string in the above list from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Restart SciTE and if done correctly, the option should be present!  Do this for any language listed in the above example list.&lt;br /&gt;
&lt;br /&gt;
In the case that you uncommented a language and you notice that it&#039;s not being highlighted correctly, then we will have to edit some things in the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file in a text editor and find the section&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# import properties\all the language specific properties files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Below that section there will be a few strings that look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#import properties\[syntax]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Uncomment the syntax related property you wish to have support for.&lt;br /&gt;
&lt;br /&gt;
Say you wanted support for ruby, just locate the one that says &#039;&#039;ruby&#039;&#039; where &#039;&#039;[syntax]&#039;&#039; is written.&lt;br /&gt;
&lt;br /&gt;
==Colors in the Output Pane==&lt;br /&gt;
When you use SciTE as your AutoIt script editor it is a simple matter to get color in the output pane while you test run your code. Try this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;AutoIt&amp;quot;&amp;gt;&lt;br /&gt;
 ConsoleWrite(&amp;quot;This is plain text&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;&amp;gt;Make it have some color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;+Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;-Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;!Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging Code Easily==&lt;br /&gt;
This is one of my (@uten&#039;s) favorites.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 dbg(&amp;quot;This is a test&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;Jump to this line&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;just by clicking my output line&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 Func dbg($msg, $error = @error, $extended = @extended, $erl = @ScriptLineNumber)&lt;br /&gt;
     ConsoleWrite(&amp;quot;(&amp;quot; &amp;amp; $erl &amp;amp; &amp;quot;) : = (&amp;quot; &amp;amp; $error &amp;amp; &amp;quot;)(&amp;quot; &amp;amp; $extended &amp;amp; &amp;quot;) &amp;quot; &amp;amp; $msg &amp;amp; @LF)&lt;br /&gt;
     If $error &amp;lt;&amp;gt; 0 Then SetError($error, $extended, $error)&lt;br /&gt;
     Return $error&lt;br /&gt;
 EndFunc   ;==&amp;gt;dbg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=AutoIt3Wrapper=&lt;br /&gt;
AutoIt3Wrapper directives allow much greater and in depth control of your resulting programs. Some of these can be very useful under different circumstances.&lt;br /&gt;
&lt;br /&gt;
==Stripping Excess Code==&lt;br /&gt;
For instance, if you have several includes, then you can often strip thousands of lines from your program using obfuscator:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_Obfuscator=y&lt;br /&gt;
 #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0&lt;br /&gt;
&lt;br /&gt;
On a medium sized script, results are often like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running Obfuscator (1.0.27.0)  from:C:\Program Files\AutoIt3\SciTE cmdline:&lt;br /&gt;
 - Iteration 1 Strip Functions result: Output  2580 lines and stripped 6741 lines&lt;br /&gt;
 - Iteration 2 Strip Variables result: Output  1585 lines and stripped 950 lines&lt;br /&gt;
 - Iteration 3 Strip Variables result: Output  1566 lines and stripped 19 lines&lt;br /&gt;
 - Iteration 4 Start the actual Obfuscation.&lt;br /&gt;
 +&amp;gt; Source    26190 lines 1447980 Characters.&lt;br /&gt;
 +&amp;gt; Stripped  7710 Func/Var lines and  16862 comment lines, Total 1373871 Characters.&lt;br /&gt;
 +&amp;gt; Saved     93% lines 94% Characters.&lt;br /&gt;
 +&amp;gt; Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3&lt;br /&gt;
&lt;br /&gt;
==Using ResHacker==&lt;br /&gt;
ResHacker is a very important programming tool for extracting and adding resources into executables. It has a very simple command line interface that allows it to be used easily using the &amp;quot;Run_After&amp;quot; directive. Adding a picture to an executable could be done like this:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
&lt;br /&gt;
*NB:* Reshacker.exe &#039;&#039;must&#039;&#039; be copied into the script directory for this to work!&lt;br /&gt;
&lt;br /&gt;
If you then want to use the resources in your code, there is an excellent [http://www.autoitscript.com/forum/index.php?showtopic=51103 Resources UDF] which will allow you to access the resources from within the exe.&lt;br /&gt;
&lt;br /&gt;
==Adding Original Source Code==&lt;br /&gt;
When using the above tip on stripping excess code, the new source is not readable. As a result, using the standard directive for saving the source:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Res_SaveSource=y&lt;br /&gt;
&lt;br /&gt;
Would add the obfuscated code to the exe, which is not the desired result. The solution is to add it in manually. This code does not require any editing, so you can just copy and paste it in:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0&lt;br /&gt;
&lt;br /&gt;
==Creating a Version Directory==&lt;br /&gt;
When compiling, it is very possible that you want to go back to a previous version. If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time! Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=md &amp;quot;%scriptdir%\Versions\%fileversion%&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%in%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%out%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Running the exe on Build==&lt;br /&gt;
Often you are building as a test, so to have to open up Windows Explorer to get the exe is a pain, furthermore, unless you have a program to do it (or it&#039;s a console program) you will not be able to read console info such as the debug messages you put in the exe. The solution is simple:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=&amp;quot;%out%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will run the program and read the console output to the SciTE debug frame.&lt;br /&gt;
&lt;br /&gt;
==Extended Reshacker Info==&lt;br /&gt;
ResHacker doesn&#039;t always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=TYPE ResHacker.log&lt;br /&gt;
&lt;br /&gt;
The new output now looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running:ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:26:22]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
  Added: BITMAP,RESOURCENAME,0&lt;br /&gt;
 &lt;br /&gt;
 Commands completed&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
And an example of it showing an error:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:32:10]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 Error: &amp;quot;MyPicture.bmp&amp;quot; does not exist&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
As you can see, Reshacker on its own returns rc: 0, usually indicating no error. This would have gone completely unnoticed except for the log file, which shows the error and an explanation.&lt;br /&gt;
&lt;br /&gt;
==Other Run_After and Run_Before Commands==&lt;br /&gt;
You can use any commands you like in the Run_After and Run_Before directives. Examples such as &amp;quot;TYPE&amp;quot; have been shown above. &lt;br /&gt;
&lt;br /&gt;
For a more complete list the following website is very useful: [http://ss64.com/nt An A-Z Index of the Windows CMD Line]&lt;br /&gt;
&lt;br /&gt;
=Other Wiki Pages=&lt;br /&gt;
[[Adding_utilities_to_the_SciTE_Tools_menu|Adding Utilities to the SciTE Tools Menu]]&lt;br /&gt;
&lt;br /&gt;
[[Adding_UDFs_to_AutoIt_and_SciTE|Adding UDFs to AutoIt and SciTE]]&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11276</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11276"/>
		<updated>2012-11-12T17:59:58Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Debugging Code Easily */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SciTE4AutoIt3=&lt;br /&gt;
SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  SciTE has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &#039;&#039;SciTEConfig&#039;&#039; under the &#039;&#039;Tools&#039;&#039; menu.  With &#039;&#039;SciTEConfig&#039;&#039; a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s &#039;&#039;Tools&#039;&#039; menu.  Also available are calltips, abbreviations, autocompletion, code folding and quick access to the help file.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that SciTE4AutoIt3 is not an official package.  Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.&lt;br /&gt;
&lt;br /&gt;
=Syntax Highlighting=&lt;br /&gt;
[[File:Syntax_Highlight.png|457px|thumb|right|A demonstration of syntax highlighting using the default theme.]]&lt;br /&gt;
SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting.  Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments, etc.  This allows one to differentiate the various code elements at a glance without having to specifically read everything.  To load a custom theme a user may press [Ctrl] + [1] to bring up &#039;&#039;SciTEConfig&#039;&#039;.  The options are located under the &#039;&#039;Color Settings&#039;&#039; tab.&lt;br /&gt;
&lt;br /&gt;
Some options that are available for customization include:&lt;br /&gt;
* White Space&lt;br /&gt;
* Comment Line&lt;br /&gt;
* Comment Block&lt;br /&gt;
* Number&lt;br /&gt;
* Function&lt;br /&gt;
* Keyword&lt;br /&gt;
* Macro&lt;br /&gt;
* String&lt;br /&gt;
&lt;br /&gt;
=Quick Tips=&lt;br /&gt;
To access the helpfile the user may press [Alt] + [F1]. &lt;br /&gt;
To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the [F1] key to bring up the help file on the relevant page.&lt;br /&gt;
&lt;br /&gt;
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation. &#039;&#039;It&#039;s recommended that you read it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For anyone not familiar with SciTE, here are a few tips and tricks to help you easily modify the installation to suit your needs. For any &amp;quot;truly&amp;quot; advanced info, you should visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].&lt;br /&gt;
&lt;br /&gt;
With the information below, you will be doing some minor editing to SciTE&#039;s configuration files.&lt;br /&gt;
It is imperative that you know the hierarchy of SciTE&#039;s configuration files. The main files we will be dealing with here are listed below.&lt;br /&gt;
&lt;br /&gt;
Remember there are four properties files used:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;SciTE.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEDirectory.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEUser.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEGlobal.properties&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTE.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEDirectory.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Directory properties file which may be present in the same or in a parent directory as the file being edited. This file overrides all properties setting of the files below, but not the local properties settings aka &#039;&#039;SciTE.properties&#039;&#039;. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEUser.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;User properties file, this files settings override only the Global properties settings aka &#039;&#039;SciTEGlobal.properties&#039;&#039;. This file is found under the current logged on users profile directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEGlobal.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;All settings in this file can be overridden by any of the above files. Typically you shouldn&#039;t mess with this file and use any of the above methods to implement a setting change. This file can be found in SciTE&#039;s installation directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you have any trouble finding any of the previously mentioned files then I recommend that you do &#039;&#039;not&#039;&#039; continue further.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Inline Errors==&lt;br /&gt;
[[File:InlineError.JPG‎‎|234px|thumb|right|Intentional error prone code used to display the &amp;quot;Inline Error&amp;quot; feature.]]&lt;br /&gt;
In the latest version of SciTE, there exists a new feature called &amp;quot;Inline Errors&amp;quot;, some users find them annoying. Inline Error marks are error messages that will appear in the source code within the Scintilla window. While helpful, some users prefer to disable this feature often for unknown reasons.&lt;br /&gt;
You can quickly disable/enable them using the &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Open the SciTE user properties file in a text editor and add the following code to the file.&lt;br /&gt;
&lt;br /&gt;
To disable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To enable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Selection Highlighting==&lt;br /&gt;
In the latest SciTE4AutoIt3, there is a new feature which highlights other instances of the currently highlighted word or string. Due to the colors, sometimes it&#039;s hard to tell the selection apart.&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like, you can do either of two things using the &#039;&#039;SciTEUser.properties&#039;&#039;.&lt;br /&gt;
# Disable it&lt;br /&gt;
# Change the color scheme&lt;br /&gt;
&lt;br /&gt;
To disable it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To re-enable it, just delete it and save.&lt;br /&gt;
&lt;br /&gt;
To change the color scheme, add the following to your SciTEUser.properties file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word.colour=#000040&lt;br /&gt;
selection.alpha=50&lt;br /&gt;
selection.back=#F025A8&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The user should try adjusting the &#039;&#039;#COLOR&#039;&#039; values to come to a preferred color.&lt;br /&gt;
&lt;br /&gt;
==More Language Highlighting Options==&lt;br /&gt;
In the SciTEUser.properties file, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Language Highlighting Options&lt;br /&gt;
menu.language=\&lt;br /&gt;
#FreeBasic|bas||\&lt;br /&gt;
Text|txt|Shift+F11|\&lt;br /&gt;
#Ada|ads||\&lt;br /&gt;
AutoIt3|au3|Shift+F12|\&lt;br /&gt;
#Apache Confi&amp;amp;g|conf||\&lt;br /&gt;
#Assembler|asm||\&lt;br /&gt;
#ASN.1|asn1||\&lt;br /&gt;
#Avenue|ave||\&lt;br /&gt;
#Baan|bc||\&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
#Bullant|ant||\&lt;br /&gt;
#&amp;amp;C / C++|cpp||\&lt;br /&gt;
#CMake|cmake||\&lt;br /&gt;
#C&amp;amp;#|cs||\&lt;br /&gt;
#COBOL|cob||\&lt;br /&gt;
#Csound|orc||\&lt;br /&gt;
#CSS|css||\&lt;br /&gt;
#D|d||\&lt;br /&gt;
#&amp;amp;Difference|diff||\&lt;br /&gt;
#&amp;amp;Eiffel|e||\&lt;br /&gt;
#Erlang|erl||\&lt;br /&gt;
#&amp;amp;Errorlist|err||\&lt;br /&gt;
#FlagShip|prg||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#Gap|g||\&lt;br /&gt;
#Haskell|hs||\&lt;br /&gt;
#H&amp;amp;ypertext|html|$(keyHTML)|\&lt;br /&gt;
#&amp;amp;InnoSetup|iss||\&lt;br /&gt;
#&amp;amp;Java|java||\&lt;br /&gt;
#Java&amp;amp;Script|js||\&lt;br /&gt;
#&amp;amp;Kix|kix||\&lt;br /&gt;
#Lisp|lisp||\&lt;br /&gt;
#Lot|lot||\&lt;br /&gt;
#Lout|lt||\&lt;br /&gt;
#Lu&amp;amp;a|lua||\&lt;br /&gt;
#Matlab|m.matlab||\&lt;br /&gt;
#&amp;amp;Makefile|mak||\&lt;br /&gt;
#MetaPost|mp||\&lt;br /&gt;
#MMIXAL|mms||\&lt;br /&gt;
#Modula-3|m3||\&lt;br /&gt;
#&amp;amp;nnCron crontab|tab||\&lt;br /&gt;
#NSIS|nsis||\&lt;br /&gt;
#Objective Caml|ml||\&lt;br /&gt;
#Octave|m.octave||\&lt;br /&gt;
#Opal|impl||\&lt;br /&gt;
#Pascal|pas||\&lt;br /&gt;
#Pe&amp;amp;rl|pl||\&lt;br /&gt;
#P&amp;amp;HP|php||\&lt;br /&gt;
#P&amp;amp;LSQL|spec||\&lt;br /&gt;
#P&amp;amp;ostScript|ps||\&lt;br /&gt;
#P&amp;amp;OV-Ray SDL|pov||\&lt;br /&gt;
#PowerShell|ps1||\&lt;br /&gt;
#PowerPro|powerpro||\&lt;br /&gt;
#&amp;amp;Properties|properties||\&lt;br /&gt;
#Pytho&amp;amp;n|py||\&lt;br /&gt;
#R|R||\&lt;br /&gt;
#Reso&amp;amp;urce|rc||\&lt;br /&gt;
#Ruby|rb||\&lt;br /&gt;
#Shell|sh||\&lt;br /&gt;
#S&amp;amp;QL|sql||\&lt;br /&gt;
#Specman|e||\&lt;br /&gt;
#&amp;amp;TCL|tcl||\&lt;br /&gt;
#TeX|tex||\&lt;br /&gt;
#&amp;amp;txt2tags|t2t||\&lt;br /&gt;
#&amp;amp;VB|vb||\&lt;br /&gt;
#VBScr&amp;amp;ipt|vbs||\&lt;br /&gt;
#Verilog|v||\&lt;br /&gt;
#VHDL|vhd||\&lt;br /&gt;
#&amp;amp;XML|xml||\&lt;br /&gt;
#&amp;amp;YAML|yaml||&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For whatever language you wish to have an option appear under the &#039;&#039;Language&#039;&#039; menu option, uncomment the language.  Say you want to SciTE to give you the option to highlight batch script code, change the following string in the above list from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Restart SciTE and if done correctly, the option should be present!  Do this for any language listed in the above example list.&lt;br /&gt;
&lt;br /&gt;
In the case that you uncommented a language and you notice that it&#039;s not being highlighted correctly, then we will have to edit some things in the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file in a text editor and find the section&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# import properties\all the language specific properties files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Below that section there will be a few strings that look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#import properties\[syntax]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Uncomment the syntax related property you wish to have support for.&lt;br /&gt;
&lt;br /&gt;
Say you wanted support for ruby, just locate the one that says &#039;&#039;ruby&#039;&#039; where &#039;&#039;[syntax]&#039;&#039; is written.&lt;br /&gt;
&lt;br /&gt;
==Colors in the Output Pane==&lt;br /&gt;
When you use SciTE as your AutoIt script editor it is a simple matter to get color in the output pane while you test run your code. Try this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;AutoIt&amp;quot;&amp;gt;&lt;br /&gt;
 ConsoleWrite(&amp;quot;This is plain text&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;&amp;gt;Make it have some color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;+Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;-Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;!Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging Code Easily==&lt;br /&gt;
This is one of my (@uten&#039;s) favorites.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 dbg(&amp;quot;This is a test&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;Jump to this line&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;just by clicking my output line&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 Func dbg($msg, $error = @error, $extended = @extended, $erl = @ScriptLineNumber)&lt;br /&gt;
     ConsoleWrite(&amp;quot;(&amp;quot; &amp;amp; $erl &amp;amp; &amp;quot;) : = (&amp;quot; &amp;amp; $error &amp;amp; &amp;quot;)(&amp;quot; &amp;amp; $extended &amp;amp; &amp;quot;) &amp;quot; &amp;amp; $msg &amp;amp; @LF)&lt;br /&gt;
     If $error &amp;lt;&amp;gt; 0 Then SetError($error, $extended, $error)&lt;br /&gt;
     Return $error&lt;br /&gt;
 EndFunc   ;==&amp;gt;dbg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=AutoIt3Wrapper=&lt;br /&gt;
AutoIt3Wrapper directives allow much greater and in depth control of your resulting programs. Some of these can be very useful under different circumstances.&lt;br /&gt;
&lt;br /&gt;
==Stripping Excess Code==&lt;br /&gt;
For instance, if you have several includes, then you can often strip thousands of lines from your program using obfuscator:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_Obfuscator=y&lt;br /&gt;
 #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0&lt;br /&gt;
&lt;br /&gt;
On a medium sized script, results are often like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running Obfuscator (1.0.27.0)  from:C:\Program Files\AutoIt3\SciTE cmdline:&lt;br /&gt;
 - Iteration 1 Strip Functions result: Output  2580 lines and stripped 6741 lines&lt;br /&gt;
 - Iteration 2 Strip Variables result: Output  1585 lines and stripped 950 lines&lt;br /&gt;
 - Iteration 3 Strip Variables result: Output  1566 lines and stripped 19 lines&lt;br /&gt;
 - Iteration 4 Start the actual Obfuscation.&lt;br /&gt;
 +&amp;gt; Source    26190 lines 1447980 Characters.&lt;br /&gt;
 +&amp;gt; Stripped  7710 Func/Var lines and  16862 comment lines, Total 1373871 Characters.&lt;br /&gt;
 +&amp;gt; Saved     93% lines 94% Characters.&lt;br /&gt;
 +&amp;gt; Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3&lt;br /&gt;
&lt;br /&gt;
==Using ResHacker==&lt;br /&gt;
ResHacker is a very important programming tool for extracting and adding resources into executables. It has a very simple command line interface that allows it to be used easily using the &amp;quot;Run_After&amp;quot; directive. Adding a picture to an executable could be done like this:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
&lt;br /&gt;
*NB:* Reshacker.exe &#039;&#039;must&#039;&#039; be copied into the script directory for this to work!&lt;br /&gt;
&lt;br /&gt;
If you then want to use the resources in your code, there is an excellent [http://www.autoitscript.com/forum/index.php?showtopic=51103 Resources UDF] which will allow you to access the resources from within the exe.&lt;br /&gt;
&lt;br /&gt;
==Adding Original Source Code==&lt;br /&gt;
When using the above tip on stripping excess code, the new source is not readable. As a result, using the standard directive for saving the source:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Res_SaveSource=y&lt;br /&gt;
&lt;br /&gt;
Would add the obfuscated code to the exe, which is not the desired result. The solution is to add it in manually. This code does not require any editing, so you can just copy and paste it in:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0&lt;br /&gt;
&lt;br /&gt;
==Creating a Version Directory==&lt;br /&gt;
When compiling, it is very possible that you want to go back to a previous version. If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time! Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=md &amp;quot;%scriptdir%\Versions\%fileversion%&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%in%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%out%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Running the exe on Build==&lt;br /&gt;
Often you are building as a test, so to have to open up Windows Explorer to get the exe is a pain, furthermore, unless you have a program to do it (or it&#039;s a console program) you will not be able to read console info such as the debug messages you put in the exe. The solution is simple:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=&amp;quot;%out%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will run the program and read the console output to the SciTE debug frame.&lt;br /&gt;
&lt;br /&gt;
==Extended Reshacker Info==&lt;br /&gt;
ResHacker doesn&#039;t always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=TYPE ResHacker.log&lt;br /&gt;
&lt;br /&gt;
The new output now looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running:ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:26:22]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
  Added: BITMAP,RESOURCENAME,0&lt;br /&gt;
 &lt;br /&gt;
 Commands completed&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
And an example of it showing an error:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:32:10]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 Error: &amp;quot;MyPicture.bmp&amp;quot; does not exist&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
As you can see, Reshacker on its own returns rc: 0, usually indicating no error. This would have gone completely unnoticed except for the log file, which shows the error and an explanation.&lt;br /&gt;
&lt;br /&gt;
==Other Run_After and Run_Before Commands==&lt;br /&gt;
You can use any commands you like in the Run_After and Run_Before directives. Examples such as &amp;quot;TYPE&amp;quot; have been shown above. &lt;br /&gt;
&lt;br /&gt;
For a more complete list the following website is very useful: [http://ss64.com/nt An A-Z Index of the Windows CMD Line]&lt;br /&gt;
&lt;br /&gt;
=Other Wiki Pages=&lt;br /&gt;
[[Adding_utilities_to_the_SciTE_Tools_menu|Adding Utilities to the SciTE Tools Menu]]&lt;br /&gt;
&lt;br /&gt;
[[Adding_UDFs_to_AutoIt_and_SciTE|Adding UDFs to AutoIt and SciTE]]&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11275</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=11275"/>
		<updated>2012-11-12T17:59:40Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Colors in the Output Pane */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=SciTE4AutoIt3=&lt;br /&gt;
SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  SciTE has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &#039;&#039;SciTEConfig&#039;&#039; under the &#039;&#039;Tools&#039;&#039; menu.  With &#039;&#039;SciTEConfig&#039;&#039; a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s &#039;&#039;Tools&#039;&#039; menu.  Also available are calltips, abbreviations, autocompletion, code folding and quick access to the help file.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that SciTE4AutoIt3 is not an official package.  Direct any bug reports or feature requests to the AutoIt3 forum and not the bug tracker.&lt;br /&gt;
&lt;br /&gt;
=Syntax Highlighting=&lt;br /&gt;
[[File:Syntax_Highlight.png|457px|thumb|right|A demonstration of syntax highlighting using the default theme.]]&lt;br /&gt;
SciTE4AutoIt3 comes with a customized AutoIt3 lexer which enables syntax highlighting.  Syntax highlighting enables the colorization of various code elements such as variables, strings, operators, comments, etc.  This allows one to differentiate the various code elements at a glance without having to specifically read everything.  To load a custom theme a user may press [Ctrl] + [1] to bring up &#039;&#039;SciTEConfig&#039;&#039;.  The options are located under the &#039;&#039;Color Settings&#039;&#039; tab.&lt;br /&gt;
&lt;br /&gt;
Some options that are available for customization include:&lt;br /&gt;
* White Space&lt;br /&gt;
* Comment Line&lt;br /&gt;
* Comment Block&lt;br /&gt;
* Number&lt;br /&gt;
* Function&lt;br /&gt;
* Keyword&lt;br /&gt;
* Macro&lt;br /&gt;
* String&lt;br /&gt;
&lt;br /&gt;
=Quick Tips=&lt;br /&gt;
To access the helpfile the user may press [Alt] + [F1]. &lt;br /&gt;
To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the [F1] key to bring up the help file on the relevant page.&lt;br /&gt;
&lt;br /&gt;
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation. &#039;&#039;It&#039;s recommended that you read it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For anyone not familiar with SciTE, here are a few tips and tricks to help you easily modify the installation to suit your needs. For any &amp;quot;truly&amp;quot; advanced info, you should visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].&lt;br /&gt;
&lt;br /&gt;
With the information below, you will be doing some minor editing to SciTE&#039;s configuration files.&lt;br /&gt;
It is imperative that you know the hierarchy of SciTE&#039;s configuration files. The main files we will be dealing with here are listed below.&lt;br /&gt;
&lt;br /&gt;
Remember there are four properties files used:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;SciTE.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEDirectory.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEUser.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEGlobal.properties&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTE.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEDirectory.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Directory properties file which may be present in the same or in a parent directory as the file being edited. This file overrides all properties setting of the files below, but not the local properties settings aka &#039;&#039;SciTE.properties&#039;&#039;. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEUser.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;User properties file, this files settings override only the Global properties settings aka &#039;&#039;SciTEGlobal.properties&#039;&#039;. This file is found under the current logged on users profile directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEGlobal.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;All settings in this file can be overridden by any of the above files. Typically you shouldn&#039;t mess with this file and use any of the above methods to implement a setting change. This file can be found in SciTE&#039;s installation directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you have any trouble finding any of the previously mentioned files then I recommend that you do &#039;&#039;not&#039;&#039; continue further.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Inline Errors==&lt;br /&gt;
[[File:InlineError.JPG‎‎|234px|thumb|right|Intentional error prone code used to display the &amp;quot;Inline Error&amp;quot; feature.]]&lt;br /&gt;
In the latest version of SciTE, there exists a new feature called &amp;quot;Inline Errors&amp;quot;, some users find them annoying. Inline Error marks are error messages that will appear in the source code within the Scintilla window. While helpful, some users prefer to disable this feature often for unknown reasons.&lt;br /&gt;
You can quickly disable/enable them using the &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Open the SciTE user properties file in a text editor and add the following code to the file.&lt;br /&gt;
&lt;br /&gt;
To disable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To enable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Selection Highlighting==&lt;br /&gt;
In the latest SciTE4AutoIt3, there is a new feature which highlights other instances of the currently highlighted word or string. Due to the colors, sometimes it&#039;s hard to tell the selection apart.&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like, you can do either of two things using the &#039;&#039;SciTEUser.properties&#039;&#039;.&lt;br /&gt;
# Disable it&lt;br /&gt;
# Change the color scheme&lt;br /&gt;
&lt;br /&gt;
To disable it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To re-enable it, just delete it and save.&lt;br /&gt;
&lt;br /&gt;
To change the color scheme, add the following to your SciTEUser.properties file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word.colour=#000040&lt;br /&gt;
selection.alpha=50&lt;br /&gt;
selection.back=#F025A8&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The user should try adjusting the &#039;&#039;#COLOR&#039;&#039; values to come to a preferred color.&lt;br /&gt;
&lt;br /&gt;
==More Language Highlighting Options==&lt;br /&gt;
In the SciTEUser.properties file, add the following code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Language Highlighting Options&lt;br /&gt;
menu.language=\&lt;br /&gt;
#FreeBasic|bas||\&lt;br /&gt;
Text|txt|Shift+F11|\&lt;br /&gt;
#Ada|ads||\&lt;br /&gt;
AutoIt3|au3|Shift+F12|\&lt;br /&gt;
#Apache Confi&amp;amp;g|conf||\&lt;br /&gt;
#Assembler|asm||\&lt;br /&gt;
#ASN.1|asn1||\&lt;br /&gt;
#Avenue|ave||\&lt;br /&gt;
#Baan|bc||\&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
#Bullant|ant||\&lt;br /&gt;
#&amp;amp;C / C++|cpp||\&lt;br /&gt;
#CMake|cmake||\&lt;br /&gt;
#C&amp;amp;#|cs||\&lt;br /&gt;
#COBOL|cob||\&lt;br /&gt;
#Csound|orc||\&lt;br /&gt;
#CSS|css||\&lt;br /&gt;
#D|d||\&lt;br /&gt;
#&amp;amp;Difference|diff||\&lt;br /&gt;
#&amp;amp;Eiffel|e||\&lt;br /&gt;
#Erlang|erl||\&lt;br /&gt;
#&amp;amp;Errorlist|err||\&lt;br /&gt;
#FlagShip|prg||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#Gap|g||\&lt;br /&gt;
#Haskell|hs||\&lt;br /&gt;
#H&amp;amp;ypertext|html|$(keyHTML)|\&lt;br /&gt;
#&amp;amp;InnoSetup|iss||\&lt;br /&gt;
#&amp;amp;Java|java||\&lt;br /&gt;
#Java&amp;amp;Script|js||\&lt;br /&gt;
#&amp;amp;Kix|kix||\&lt;br /&gt;
#Lisp|lisp||\&lt;br /&gt;
#Lot|lot||\&lt;br /&gt;
#Lout|lt||\&lt;br /&gt;
#Lu&amp;amp;a|lua||\&lt;br /&gt;
#Matlab|m.matlab||\&lt;br /&gt;
#&amp;amp;Makefile|mak||\&lt;br /&gt;
#MetaPost|mp||\&lt;br /&gt;
#MMIXAL|mms||\&lt;br /&gt;
#Modula-3|m3||\&lt;br /&gt;
#&amp;amp;nnCron crontab|tab||\&lt;br /&gt;
#NSIS|nsis||\&lt;br /&gt;
#Objective Caml|ml||\&lt;br /&gt;
#Octave|m.octave||\&lt;br /&gt;
#Opal|impl||\&lt;br /&gt;
#Pascal|pas||\&lt;br /&gt;
#Pe&amp;amp;rl|pl||\&lt;br /&gt;
#P&amp;amp;HP|php||\&lt;br /&gt;
#P&amp;amp;LSQL|spec||\&lt;br /&gt;
#P&amp;amp;ostScript|ps||\&lt;br /&gt;
#P&amp;amp;OV-Ray SDL|pov||\&lt;br /&gt;
#PowerShell|ps1||\&lt;br /&gt;
#PowerPro|powerpro||\&lt;br /&gt;
#&amp;amp;Properties|properties||\&lt;br /&gt;
#Pytho&amp;amp;n|py||\&lt;br /&gt;
#R|R||\&lt;br /&gt;
#Reso&amp;amp;urce|rc||\&lt;br /&gt;
#Ruby|rb||\&lt;br /&gt;
#Shell|sh||\&lt;br /&gt;
#S&amp;amp;QL|sql||\&lt;br /&gt;
#Specman|e||\&lt;br /&gt;
#&amp;amp;TCL|tcl||\&lt;br /&gt;
#TeX|tex||\&lt;br /&gt;
#&amp;amp;txt2tags|t2t||\&lt;br /&gt;
#&amp;amp;VB|vb||\&lt;br /&gt;
#VBScr&amp;amp;ipt|vbs||\&lt;br /&gt;
#Verilog|v||\&lt;br /&gt;
#VHDL|vhd||\&lt;br /&gt;
#&amp;amp;XML|xml||\&lt;br /&gt;
#&amp;amp;YAML|yaml||&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For whatever language you wish to have an option appear under the &#039;&#039;Language&#039;&#039; menu option, uncomment the language.  Say you want to SciTE to give you the option to highlight batch script code, change the following string in the above list from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Restart SciTE and if done correctly, the option should be present!  Do this for any language listed in the above example list.&lt;br /&gt;
&lt;br /&gt;
In the case that you uncommented a language and you notice that it&#039;s not being highlighted correctly, then we will have to edit some things in the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file in a text editor and find the section&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# import properties\all the language specific properties files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Below that section there will be a few strings that look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#import properties\[syntax]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Uncomment the syntax related property you wish to have support for.&lt;br /&gt;
&lt;br /&gt;
Say you wanted support for ruby, just locate the one that says &#039;&#039;ruby&#039;&#039; where &#039;&#039;[syntax]&#039;&#039; is written.&lt;br /&gt;
&lt;br /&gt;
==Colors in the Output Pane==&lt;br /&gt;
When you use SciTE as your AutoIt script editor it is a simple matter to get color in the output pane while you test run your code. Try this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;AutoIt&amp;quot;&amp;gt;&lt;br /&gt;
 ConsoleWrite(&amp;quot;This is plain text&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;&amp;gt;Make it have some color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;+Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;-Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
 ConsoleWrite(&amp;quot;!Make it have some other color&amp;quot; &amp;amp; @LF)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging Code Easily==&lt;br /&gt;
This is one of my (@uten&#039;s) favorites.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
 dbg(&amp;quot;This is a test&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;Jump to this line&amp;quot;)&lt;br /&gt;
 dbg(&amp;quot;just by clicking my output line&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
 Func dbg($msg, $error = @error, $extended = @extended, $erl = @ScriptLineNumber)&lt;br /&gt;
     ConsoleWrite(&amp;quot;(&amp;quot; &amp;amp; $erl &amp;amp; &amp;quot;) : = (&amp;quot; &amp;amp; $error &amp;amp; &amp;quot;)(&amp;quot; &amp;amp; $extended &amp;amp; &amp;quot;) &amp;quot; &amp;amp; $msg &amp;amp; @LF)&lt;br /&gt;
     If $error &amp;lt;&amp;gt; 0 Then SetError($error, $extended, $error)&lt;br /&gt;
     Return $error&lt;br /&gt;
 EndFunc   ;==&amp;gt;dbg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=AutoIt3Wrapper=&lt;br /&gt;
AutoIt3Wrapper directives allow much greater and in depth control of your resulting programs. Some of these can be very useful under different circumstances.&lt;br /&gt;
&lt;br /&gt;
==Stripping Excess Code==&lt;br /&gt;
For instance, if you have several includes, then you can often strip thousands of lines from your program using obfuscator:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_Obfuscator=y&lt;br /&gt;
 #Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0&lt;br /&gt;
&lt;br /&gt;
On a medium sized script, results are often like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running Obfuscator (1.0.27.0)  from:C:\Program Files\AutoIt3\SciTE cmdline:&lt;br /&gt;
 - Iteration 1 Strip Functions result: Output  2580 lines and stripped 6741 lines&lt;br /&gt;
 - Iteration 2 Strip Variables result: Output  1585 lines and stripped 950 lines&lt;br /&gt;
 - Iteration 3 Strip Variables result: Output  1566 lines and stripped 19 lines&lt;br /&gt;
 - Iteration 4 Start the actual Obfuscation.&lt;br /&gt;
 +&amp;gt; Source    26190 lines 1447980 Characters.&lt;br /&gt;
 +&amp;gt; Stripped  7710 Func/Var lines and  16862 comment lines, Total 1373871 Characters.&lt;br /&gt;
 +&amp;gt; Saved     93% lines 94% Characters.&lt;br /&gt;
 +&amp;gt; Obfuscator v1.0.27.0 finished obfuscating 1566 lines, created:C:\MyScript_Obfuscated.au3&lt;br /&gt;
&lt;br /&gt;
==Using ResHacker==&lt;br /&gt;
ResHacker is a very important programming tool for extracting and adding resources into executables. It has a very simple command line interface that allows it to be used easily using the &amp;quot;Run_After&amp;quot; directive. Adding a picture to an executable could be done like this:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
&lt;br /&gt;
*NB:* Reshacker.exe &#039;&#039;must&#039;&#039; be copied into the script directory for this to work!&lt;br /&gt;
&lt;br /&gt;
If you then want to use the resources in your code, there is an excellent [http://www.autoitscript.com/forum/index.php?showtopic=51103 Resources UDF] which will allow you to access the resources from within the exe.&lt;br /&gt;
&lt;br /&gt;
==Adding Original Source Code==&lt;br /&gt;
When using the above tip on stripping excess code, the new source is not readable. As a result, using the standard directive for saving the source:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Res_SaveSource=y&lt;br /&gt;
&lt;br /&gt;
Would add the obfuscated code to the exe, which is not the desired result. The solution is to add it in manually. This code does not require any editing, so you can just copy and paste it in:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, %scriptfile%.au3, RCDATA, SOURCE, 0&lt;br /&gt;
&lt;br /&gt;
==Creating a Version Directory==&lt;br /&gt;
When compiling, it is very possible that you want to go back to a previous version. If so, then it is neat to have a directory which will store all previous builds, without the need for you to manually copy and paste every time! Make sure you add these directives in last (after adding resources) as they might not be included in the copied result.&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=md &amp;quot;%scriptdir%\Versions\%fileversion%&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%in%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.au3&amp;quot;&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=copy &amp;quot;%out%&amp;quot; &amp;quot;%scriptdir%\Versions\%fileversion%\%scriptfile%%fileversion%.exe&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Running the exe on Build==&lt;br /&gt;
Often you are building as a test, so to have to open up Windows Explorer to get the exe is a pain, furthermore, unless you have a program to do it (or it&#039;s a console program) you will not be able to read console info such as the debug messages you put in the exe. The solution is simple:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=&amp;quot;%out%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This will run the program and read the console output to the SciTE debug frame.&lt;br /&gt;
&lt;br /&gt;
==Extended Reshacker Info==&lt;br /&gt;
ResHacker doesn&#039;t always return with a return code (rc) of not 0 if it fails, to get that info you need to read the ResHacker.log file that is created. This is also pretty simple to do:&lt;br /&gt;
&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=ResHacker.exe -add %out%, %out%, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 #AutoIt3Wrapper_Run_After=TYPE ResHacker.log&lt;br /&gt;
&lt;br /&gt;
The new output now looks like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;Running:ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:26:22]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
  Added: BITMAP,RESOURCENAME,0&lt;br /&gt;
 &lt;br /&gt;
 Commands completed&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
And an example of it showing an error:&lt;br /&gt;
&lt;br /&gt;
 &amp;gt;ResHacker.exe -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0 Ended   rc:0&lt;br /&gt;
 &amp;gt;Running:TYPE ResHacker.log&lt;br /&gt;
 [19 Jan 2010, 21:32:10]&lt;br /&gt;
 ResHacker.exe  -add C:\MyScript.exe, C:\MyScript.exe, MyPicture.bmp, BITMAP, RESOURCENAME, 0&lt;br /&gt;
 Error: &amp;quot;MyPicture.bmp&amp;quot; does not exist&lt;br /&gt;
 &amp;gt;TYPE ResHacker.log Ended   rc:0&lt;br /&gt;
&lt;br /&gt;
As you can see, Reshacker on its own returns rc: 0, usually indicating no error. This would have gone completely unnoticed except for the log file, which shows the error and an explanation.&lt;br /&gt;
&lt;br /&gt;
==Other Run_After and Run_Before Commands==&lt;br /&gt;
You can use any commands you like in the Run_After and Run_Before directives. Examples such as &amp;quot;TYPE&amp;quot; have been shown above. &lt;br /&gt;
&lt;br /&gt;
For a more complete list the following website is very useful: [http://ss64.com/nt An A-Z Index of the Windows CMD Line]&lt;br /&gt;
&lt;br /&gt;
=Other Wiki Pages=&lt;br /&gt;
[[Adding_utilities_to_the_SciTE_Tools_menu|Adding Utilities to the SciTE Tools Menu]]&lt;br /&gt;
&lt;br /&gt;
[[Adding_UDFs_to_AutoIt_and_SciTE|Adding UDFs to AutoIt and SciTE]]&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10951</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10951"/>
		<updated>2012-11-10T03:28:49Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Defining */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&amp;lt;!-- NOTE: It would be nice if we could keep most of the code in here &amp;quot;runable&amp;quot;, so that a user reading around can just copy and paste the code into SciTE for a quick user friendly demonstration --&amp;gt;&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ; Your customized code will go in here&lt;br /&gt;
    ; then you can call this function and have your code executed or &amp;quot;run&amp;quot;&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
MyUDFAcceptingArguments(&amp;quot;Some string&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Func MyUDFAcceptingArguments($arg1, $arg2 = &amp;quot;Default Data&amp;quot;)&lt;br /&gt;
    MsgBox(64, $arg1, $arg2)&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $sReturn = _MyUDF_ReturnResults()&lt;br /&gt;
ConsoleWrite($sReturn &amp;amp; @CR); Display what was returned, we add @CR or @LF to drop down a line break, remove to see what happens&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults()&lt;br /&gt;
	Local $sTest = &amp;quot;Some information&amp;quot;; this will be returned&lt;br /&gt;
        ; The Return statement will tell the function to return the information in the $Is variable&lt;br /&gt;
	Return $sTest&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10950</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10950"/>
		<updated>2012-11-10T03:26:46Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Returning data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&amp;lt;!-- NOTE: It would be nice if we could keep most of the code in here &amp;quot;runable&amp;quot;, so that a user reading around can just copy and paste the code into SciTE for a quick user friendly demonstration --&amp;gt;&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
MyUDFAcceptingArguments(&amp;quot;Some string&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Func MyUDFAcceptingArguments($arg1, $arg2 = &amp;quot;Default Data&amp;quot;)&lt;br /&gt;
    MsgBox(64, $arg1, $arg2)&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $sReturn = _MyUDF_ReturnResults()&lt;br /&gt;
ConsoleWrite($sReturn &amp;amp; @CR); Display what was returned, we add @CR or @LF to drop down a line break, remove to see what happens&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults()&lt;br /&gt;
	Local $sTest = &amp;quot;Some information&amp;quot;; this will be returned&lt;br /&gt;
        ; The Return statement will tell the function to return the information in the $Is variable&lt;br /&gt;
	Return $sTest&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10949</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10949"/>
		<updated>2012-11-10T03:19:45Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Passing data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&amp;lt;!-- NOTE: It would be nice if we could keep most of the code in here &amp;quot;runable&amp;quot;, so that a user reading around can just copy and paste the code into SciTE for a quick user friendly demonstration --&amp;gt;&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
MyUDFAcceptingArguments(&amp;quot;Some string&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Func MyUDFAcceptingArguments($arg1, $arg2 = &amp;quot;Default Data&amp;quot;)&lt;br /&gt;
    MsgBox(64, $arg1, $arg2)&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
ConsoleWrite(&amp;quot;1)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;2)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10.5) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;3)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(&amp;quot;10&amp;quot;) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;4)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(True) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;5)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Default) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;6)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Binary(&amp;quot;AutoIt&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;7)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(GUICreate(&amp;quot;&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;8)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(ObjCreate(&amp;quot;shell.application&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;9)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructCreate(&amp;quot;int&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;10) &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructGetPtr(DllStructCreate(&amp;quot;char&amp;quot;))) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;11) &amp;quot; &amp;amp; _MyUDF_ReturnResults(StringSplit(&amp;quot;1.2.3&amp;quot;, &amp;quot;.&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults($arg1)&lt;br /&gt;
	Local $Is&lt;br /&gt;
	If IsNumber($arg1) Then $Is &amp;amp;= &amp;quot;NUMBER &amp;quot;&lt;br /&gt;
	If IsFloat($arg1) Then $Is &amp;amp;= &amp;quot;FLOAT &amp;quot;&lt;br /&gt;
	If IsString($arg1) Then $Is &amp;amp;= &amp;quot;STRING &amp;quot;&lt;br /&gt;
	If IsInt($arg1) Then $Is &amp;amp;= &amp;quot;INTEGER &amp;quot;&lt;br /&gt;
	If IsBinary($arg1) Then $Is &amp;amp;= &amp;quot;BINARY &amp;quot;&lt;br /&gt;
	If IsArray($arg1) Then $Is &amp;amp;= &amp;quot;ARRAY &amp;quot;&lt;br /&gt;
	If IsPtr($arg1) Then $Is &amp;amp;= &amp;quot;POINTER &amp;quot;&lt;br /&gt;
	If IsDllStruct($arg1) Then $Is &amp;amp;= &amp;quot;DLL_STRUCTURE &amp;quot;&lt;br /&gt;
	If IsHWnd($arg1) Then $Is &amp;amp;= &amp;quot;WINDOW_HANDLE &amp;quot;&lt;br /&gt;
	If IsBool($arg1) Then $Is &amp;amp;= &amp;quot;BOOL &amp;quot;&lt;br /&gt;
	If IsKeyword($arg1) Then $Is &amp;amp;= &amp;quot;KEYWORD &amp;quot;&lt;br /&gt;
	If IsObj($arg1) Then $Is &amp;amp;= &amp;quot;OBJECT &amp;quot;&lt;br /&gt;
	Return $Is&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10948</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10948"/>
		<updated>2012-11-10T03:14:18Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&amp;lt;!-- NOTE: It would be nice if we could keep most of the code in here &amp;quot;runable&amp;quot;, so that a user reading around can just copy and paste the code into SciTE for a quick user friendly demonstration --&amp;gt;&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
ConsoleWrite(&amp;quot;1)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;2)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10.5) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;3)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(&amp;quot;10&amp;quot;) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;4)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(True) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;5)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Default) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;6)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Binary(&amp;quot;AutoIt&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;7)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(GUICreate(&amp;quot;&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;8)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(ObjCreate(&amp;quot;shell.application&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;9)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructCreate(&amp;quot;int&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;10) &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructGetPtr(DllStructCreate(&amp;quot;char&amp;quot;))) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;11) &amp;quot; &amp;amp; _MyUDF_ReturnResults(StringSplit(&amp;quot;1.2.3&amp;quot;, &amp;quot;.&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults($arg1)&lt;br /&gt;
	Local $Is&lt;br /&gt;
	If IsNumber($arg1) Then $Is &amp;amp;= &amp;quot;NUMBER &amp;quot;&lt;br /&gt;
	If IsFloat($arg1) Then $Is &amp;amp;= &amp;quot;FLOAT &amp;quot;&lt;br /&gt;
	If IsString($arg1) Then $Is &amp;amp;= &amp;quot;STRING &amp;quot;&lt;br /&gt;
	If IsInt($arg1) Then $Is &amp;amp;= &amp;quot;INTEGER &amp;quot;&lt;br /&gt;
	If IsBinary($arg1) Then $Is &amp;amp;= &amp;quot;BINARY &amp;quot;&lt;br /&gt;
	If IsArray($arg1) Then $Is &amp;amp;= &amp;quot;ARRAY &amp;quot;&lt;br /&gt;
	If IsPtr($arg1) Then $Is &amp;amp;= &amp;quot;POINTER &amp;quot;&lt;br /&gt;
	If IsDllStruct($arg1) Then $Is &amp;amp;= &amp;quot;DLL_STRUCTURE &amp;quot;&lt;br /&gt;
	If IsHWnd($arg1) Then $Is &amp;amp;= &amp;quot;WINDOW_HANDLE &amp;quot;&lt;br /&gt;
	If IsBool($arg1) Then $Is &amp;amp;= &amp;quot;BOOL &amp;quot;&lt;br /&gt;
	If IsKeyword($arg1) Then $Is &amp;amp;= &amp;quot;KEYWORD &amp;quot;&lt;br /&gt;
	If IsObj($arg1) Then $Is &amp;amp;= &amp;quot;OBJECT &amp;quot;&lt;br /&gt;
	Return $Is&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10947</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10947"/>
		<updated>2012-11-10T00:10:32Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Comparing Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 cintain 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10942</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10942"/>
		<updated>2012-11-10T00:04:11Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Comparing Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
&lt;br /&gt;
If $Array1 = $Array2 then; incorrect array comparison, never do this!&lt;br /&gt;
    ConsoleWrite(&amp;quot;+&amp;gt;Array is equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
Else&lt;br /&gt;
    ConsoleWrite(&amp;quot;!&amp;gt;Array is not equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
EndIf&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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10924</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10924"/>
		<updated>2012-11-09T08:37:27Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Determine array size with UBound */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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;
&lt;br /&gt;
If $Array1 = $Array2 then&lt;br /&gt;
    ConsoleWrite(&amp;quot;+&amp;gt;Array is equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
Else&lt;br /&gt;
    ConsoleWrite(&amp;quot;!&amp;gt;Array is not equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
EndIf&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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=AutoIt_Team&amp;diff=10923</id>
		<title>AutoIt Team</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=AutoIt_Team&amp;diff=10923"/>
		<updated>2012-11-09T08:28:16Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: Created page with &amp;quot;==Administrators== * &amp;lt;span style=&amp;quot;color: #FF0000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;There is only one Admin, and that is Jon&amp;quot;&amp;gt;Jon&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/for...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Administrators==&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #FF0000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;There is only one Admin, and that is Jon&amp;quot;&amp;gt;Jon&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/1-jon/ Profile]&lt;br /&gt;
&lt;br /&gt;
==Developers==&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;Current most active developer&amp;quot;&amp;gt;Trancexx&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/33569-trancexx/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;Retired/No longer active&amp;quot;&amp;gt;Valik&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/39-valik/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;SciTE4AutoIt3 Developer&amp;quot;&amp;gt;Jos&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/19-jos/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;jpm&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/8-jpm/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;GaryFrost&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/1967-garyfrost/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;Nutster&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/88-nutster/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;tylo&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/149-tylo/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;Holger&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/1133-holger/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;DaveF&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/1944-davef/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #008000;font-weight:bold;&amp;quot;&amp;gt;SvenP&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/4276-svenp/ Profile]&lt;br /&gt;
&lt;br /&gt;
==Moderators==&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #FF0000;font-weight:bold;&amp;quot;&amp;gt;&amp;lt;abbr title=&amp;quot;Most notorious moderator&amp;quot;&amp;gt;Melba23&amp;lt;/abbr&amp;gt;&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/38576-melba23/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #FF0000;font-weight:bold;&amp;quot;&amp;gt;big_daddy&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/8730-big-daddy/ Profile]&lt;br /&gt;
* &amp;lt;span style=&amp;quot;color: #FF0000;font-weight:bold;&amp;quot;&amp;gt;SmOke_N&amp;lt;/span&amp;gt; - [http://www.autoitscript.com/forum/user/4813-smoke-n/ Profile]&lt;br /&gt;
&lt;br /&gt;
If I missed anyone, feel free to add them.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10922</id>
		<title>User:FlutterShy</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10922"/>
		<updated>2012-11-09T07:46:42Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10921</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10921"/>
		<updated>2012-11-09T07:42:54Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  The editor has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &amp;quot;SciTE Config&amp;quot; under the &amp;quot;tools&amp;quot; menu.  With &#039;&#039;SciTE Config&#039;&#039; a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default Au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s tools menu.  Also available are calltips, abbreviations, and quick access to the helpfiles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==SciTE Quick Tips==&lt;br /&gt;
&lt;br /&gt;
To access the helpfile the user may press [Alt] + [F1]. &lt;br /&gt;
To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the [F1] key to bring up the help file on a relevant page.&lt;br /&gt;
&lt;br /&gt;
For SciTE related help, use the key combination [Ctrl] + [F1] to bring up a help file detailing SciTE related help documentation. &#039;&#039;It&#039;s recommended you read it.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For anyone not familiar with SciTE, here are a few tips and tricks to help you easily modify the installation to suit your needs. For any &amp;quot;truly&amp;quot; advanced info, you should visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].&lt;br /&gt;
&lt;br /&gt;
With the information below, you will be doing some minor editing to SciTEs configuration files.&lt;br /&gt;
It is imperative that you know the hierarchy of SciTEs configuration files. The main files we will be dealing with here are listed below.&lt;br /&gt;
&lt;br /&gt;
Remember there are four properties files used:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;SciTE.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEDirectory.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEUser.properties&#039;&#039;&lt;br /&gt;
# &#039;&#039;SciTEGlobal.properties&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTE.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Local properties file which may be present in the same directory as the file being edited. This file overrides any other properties files settings below. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEDirectory.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Directory properties file which may be present in the same or in a parent directory as the file being edited. This file overrides all properties setting of the files below, but not the local properties settings aka &#039;&#039;SciTE.properties&#039;&#039;. This file is user created.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEUser.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;User properties file, this files settings override only the Global properties settings aka &#039;&#039;SciTEGlobal.properties&#039;&#039;. This file is found under the current logged on users profile directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEGlobal.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;All settings in this file can be overridden by any of the above files. Typically you shouldn&#039;t mess with this file and use any of the above methods to implement a setting change. This file can be found in SciTE&#039;s installation directory.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you&#039;re having any trouble finding any of the previously mentioned files, I recommend you NOT continue with this information...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Inline Errors===&lt;br /&gt;
[[File:InlineError.JPG‎‎|200px|thumb|right|Intentional error prone code used to display the &amp;quot;Inline Error&amp;quot; feature.]]&lt;br /&gt;
In the latest version of SciTE, there exists a new feature called &amp;quot;Inline Errors&amp;quot;, some users find them annoying. Inline Error marks are error messages that will appear in the source code within the Scintilla window. While helpful, some users prefer to disable this feature often for unknown reasons.&lt;br /&gt;
You can quickly disable/enable them using the &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Open the SciTE user properties file in a text editor and add the following code to the file.&lt;br /&gt;
&lt;br /&gt;
To disable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To enable Inline Errors, add the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Selection Highlighting===&lt;br /&gt;
In the latest SciTEforAutoIt3, there is a new feature which highlights other instances of the highlighted word or string. Due to the colors, sometimes it&#039;s hard to tell the selection apart.&lt;br /&gt;
&lt;br /&gt;
If you&#039;d like, you can do either of two things using the &#039;&#039;SciTEUser.properties&#039;&#039;.&lt;br /&gt;
# Disable it&lt;br /&gt;
# Change the color scheme&lt;br /&gt;
&lt;br /&gt;
To disable it&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To re-enable it, just delete it and save.&lt;br /&gt;
&lt;br /&gt;
To change the color scheme, add the following to your SciTEUser properties file.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
highlight.current.word.colour=#000040&lt;br /&gt;
selection.alpha=50&lt;br /&gt;
selection.back=#F025A8&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Try adjusting the &#039;&#039;#COLOR&#039;&#039; values to get an effect you&#039;d prefer.&lt;br /&gt;
&lt;br /&gt;
===More Language Highlighting Options===&lt;br /&gt;
&lt;br /&gt;
In the SciTEUser.properties file, add the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Language Highlighting Options&lt;br /&gt;
menu.language=\&lt;br /&gt;
#FreeBasic|bas||\&lt;br /&gt;
Text|txt|Shift+F11|\&lt;br /&gt;
#Ada|ads||\&lt;br /&gt;
AutoIt3|au3|Shift+F12|\&lt;br /&gt;
#Apache Confi&amp;amp;g|conf||\&lt;br /&gt;
#Assembler|asm||\&lt;br /&gt;
#ASN.1|asn1||\&lt;br /&gt;
#Avenue|ave||\&lt;br /&gt;
#Baan|bc||\&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
#Bullant|ant||\&lt;br /&gt;
#&amp;amp;C / C++|cpp||\&lt;br /&gt;
#CMake|cmake||\&lt;br /&gt;
#C&amp;amp;#|cs||\&lt;br /&gt;
#COBOL|cob||\&lt;br /&gt;
#Csound|orc||\&lt;br /&gt;
#CSS|css||\&lt;br /&gt;
#D|d||\&lt;br /&gt;
#&amp;amp;Difference|diff||\&lt;br /&gt;
#&amp;amp;Eiffel|e||\&lt;br /&gt;
#Erlang|erl||\&lt;br /&gt;
#&amp;amp;Errorlist|err||\&lt;br /&gt;
#FlagShip|prg||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#Gap|g||\&lt;br /&gt;
#Haskell|hs||\&lt;br /&gt;
#H&amp;amp;ypertext|html|$(keyHTML)|\&lt;br /&gt;
#&amp;amp;InnoSetup|iss||\&lt;br /&gt;
#&amp;amp;Java|java||\&lt;br /&gt;
#Java&amp;amp;Script|js||\&lt;br /&gt;
#&amp;amp;Kix|kix||\&lt;br /&gt;
#Lisp|lisp||\&lt;br /&gt;
#Lot|lot||\&lt;br /&gt;
#Lout|lt||\&lt;br /&gt;
#Lu&amp;amp;a|lua||\&lt;br /&gt;
#Matlab|m.matlab||\&lt;br /&gt;
#&amp;amp;Makefile|mak||\&lt;br /&gt;
#MetaPost|mp||\&lt;br /&gt;
#MMIXAL|mms||\&lt;br /&gt;
#Modula-3|m3||\&lt;br /&gt;
#&amp;amp;nnCron crontab|tab||\&lt;br /&gt;
#NSIS|nsis||\&lt;br /&gt;
#Objective Caml|ml||\&lt;br /&gt;
#Octave|m.octave||\&lt;br /&gt;
#Opal|impl||\&lt;br /&gt;
#Pascal|pas||\&lt;br /&gt;
#Pe&amp;amp;rl|pl||\&lt;br /&gt;
#P&amp;amp;HP|php||\&lt;br /&gt;
#P&amp;amp;LSQL|spec||\&lt;br /&gt;
#P&amp;amp;ostScript|ps||\&lt;br /&gt;
#P&amp;amp;OV-Ray SDL|pov||\&lt;br /&gt;
#PowerShell|ps1||\&lt;br /&gt;
#PowerPro|powerpro||\&lt;br /&gt;
#&amp;amp;Properties|properties||\&lt;br /&gt;
#Pytho&amp;amp;n|py||\&lt;br /&gt;
#R|R||\&lt;br /&gt;
#Reso&amp;amp;urce|rc||\&lt;br /&gt;
#Ruby|rb||\&lt;br /&gt;
#Shell|sh||\&lt;br /&gt;
#S&amp;amp;QL|sql||\&lt;br /&gt;
#Specman|e||\&lt;br /&gt;
#&amp;amp;TCL|tcl||\&lt;br /&gt;
#TeX|tex||\&lt;br /&gt;
#&amp;amp;txt2tags|t2t||\&lt;br /&gt;
#&amp;amp;VB|vb||\&lt;br /&gt;
#VBScr&amp;amp;ipt|vbs||\&lt;br /&gt;
#Verilog|v||\&lt;br /&gt;
#VHDL|vhd||\&lt;br /&gt;
#&amp;amp;XML|xml||\&lt;br /&gt;
#&amp;amp;YAML|yaml||&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For whatever language you wish to have an option appear under the &#039;&#039;Language&#039;&#039; menu option, uncomment the language.&lt;br /&gt;
&lt;br /&gt;
Say you want to SciTE to give you the option to highlight batch script code, change the following string in the above list from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Restart SciTE and if done correctly, the option should be present!&lt;br /&gt;
Do this for any language listed in the above example list.&lt;br /&gt;
&lt;br /&gt;
In the case that you uncommented a language and you notice that it&#039;s not being highlighted correctly, then we will have to edit some things in the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file in a text editor and find the section&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# import properties\all the language specific properties files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Below that section there will be a few strings that look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#import properties\[syntax]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Uncomment the syntax related property you wish to have support for.&lt;br /&gt;
&lt;br /&gt;
Say you wanted support for ruby, just locate the one that says &#039;&#039;ruby&#039;&#039; where &#039;&#039;[syntax]&#039;&#039; is written.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10920</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10920"/>
		<updated>2012-11-09T06:51:18Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Returning data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
ConsoleWrite(&amp;quot;1)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;2)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10.5) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;3)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(&amp;quot;10&amp;quot;) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;4)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(True) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;5)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Default) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;6)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Binary(&amp;quot;AutoIt&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;7)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(GUICreate(&amp;quot;&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;8)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(ObjCreate(&amp;quot;shell.application&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;9)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructCreate(&amp;quot;int&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;10) &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructGetPtr(DllStructCreate(&amp;quot;char&amp;quot;))) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;11) &amp;quot; &amp;amp; _MyUDF_ReturnResults(StringSplit(&amp;quot;1.2.3&amp;quot;, &amp;quot;.&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults($arg1)&lt;br /&gt;
	Local $Is&lt;br /&gt;
	If IsNumber($arg1) Then $Is &amp;amp;= &amp;quot;NUMBER &amp;quot;&lt;br /&gt;
	If IsFloat($arg1) Then $Is &amp;amp;= &amp;quot;FLOAT &amp;quot;&lt;br /&gt;
	If IsString($arg1) Then $Is &amp;amp;= &amp;quot;STRING &amp;quot;&lt;br /&gt;
	If IsInt($arg1) Then $Is &amp;amp;= &amp;quot;INTEGER &amp;quot;&lt;br /&gt;
	If IsBinary($arg1) Then $Is &amp;amp;= &amp;quot;BINARY &amp;quot;&lt;br /&gt;
	If IsArray($arg1) Then $Is &amp;amp;= &amp;quot;ARRAY &amp;quot;&lt;br /&gt;
	If IsPtr($arg1) Then $Is &amp;amp;= &amp;quot;POINTER &amp;quot;&lt;br /&gt;
	If IsDllStruct($arg1) Then $Is &amp;amp;= &amp;quot;DLL_STRUCTURE &amp;quot;&lt;br /&gt;
	If IsHWnd($arg1) Then $Is &amp;amp;= &amp;quot;WINDOW_HANDLE &amp;quot;&lt;br /&gt;
	If IsBool($arg1) Then $Is &amp;amp;= &amp;quot;BOOL &amp;quot;&lt;br /&gt;
	If IsKeyword($arg1) Then $Is &amp;amp;= &amp;quot;KEYWORD &amp;quot;&lt;br /&gt;
	If IsObj($arg1) Then $Is &amp;amp;= &amp;quot;OBJECT &amp;quot;&lt;br /&gt;
	Return $Is&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10919</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10919"/>
		<updated>2012-11-09T06:50:29Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Returning data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
ConsoleWrite(&amp;quot;1)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;2)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(10.5) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;3)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(&amp;quot;10&amp;quot;) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;4)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(True) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;5)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Default) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;6)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(Binary(&amp;quot;AutoIt&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;7)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(GUICreate(&amp;quot;&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;8)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(ObjCreate(&amp;quot;shell.application&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;9)  &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructCreate(&amp;quot;int&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;10) &amp;quot; &amp;amp; _MyUDF_ReturnResults(DllStructGetPtr(DllStructCreate(&amp;quot;char&amp;quot;))) &amp;amp; @LF)&lt;br /&gt;
ConsoleWrite(&amp;quot;11) &amp;quot; &amp;amp; _MyUDF_ReturnResults(StringSplit(&amp;quot;1.2.3&amp;quot;, &amp;quot;.&amp;quot;)) &amp;amp; @LF)&lt;br /&gt;
&lt;br /&gt;
Func _MyUDF_ReturnResults($arg1)&lt;br /&gt;
	Local $Is&lt;br /&gt;
	If IsNumber($arg1) Then $Is &amp;amp;= &amp;quot;NUMBER &amp;quot;&lt;br /&gt;
	If IsFloat($arg1) Then $Is &amp;amp;= &amp;quot;FLOAT &amp;quot;&lt;br /&gt;
	If IsString($arg1) Then $Is &amp;amp;= &amp;quot;STRING &amp;quot;&lt;br /&gt;
	If IsInt($arg1) Then $Is &amp;amp;= &amp;quot;INTEGER &amp;quot;&lt;br /&gt;
	If IsBinary($arg1) Then $Is &amp;amp;= &amp;quot;BINARY &amp;quot;&lt;br /&gt;
	If IsArray($arg1) Then $Is &amp;amp;= &amp;quot;ARRAY &amp;quot;&lt;br /&gt;
	If IsPtr($arg1) Then $Is &amp;amp;= &amp;quot;POINTER &amp;quot;&lt;br /&gt;
	If IsDllStruct($arg1) Then $Is &amp;amp;= &amp;quot;DLL_STRUCTURE &amp;quot;&lt;br /&gt;
	If IsHWnd($arg1) Then $Is &amp;amp;= &amp;quot;WINDOW_HANDLE &amp;quot;&lt;br /&gt;
	If IsBool($arg1) Then $Is = &amp;quot;BOOL &amp;quot;&lt;br /&gt;
	If IsKeyword($arg1) Then $Is &amp;amp;= &amp;quot;KEYWORD &amp;quot;&lt;br /&gt;
	If IsObj($arg1) Then $Is &amp;amp;= &amp;quot;OBJECT &amp;quot;&lt;br /&gt;
	Return $Is&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10918</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10918"/>
		<updated>2012-11-09T05:57:30Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Defining */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func MySimplestUDF(); define a simple user defined function&lt;br /&gt;
    ;Generate a random capital alphabetical letter&lt;br /&gt;
    Return Chr(Random(65, 90, 1))&lt;br /&gt;
EndFunc&lt;br /&gt;
ConsoleWrite(MySimplestUDF() &amp;amp; @LF); call the function&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10917</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10917"/>
		<updated>2012-11-09T05:50:19Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Do ... Until */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
Local $var&lt;br /&gt;
Do&lt;br /&gt;
    Sleep(100)&lt;br /&gt;
    $var += 1&lt;br /&gt;
Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
     $c += 1&lt;br /&gt;
     ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
     If $c = 2 Then ExitLoop&lt;br /&gt;
Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $c&lt;br /&gt;
Do&lt;br /&gt;
    $c += 1&lt;br /&gt;
    ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MySimplestUDF()&lt;br /&gt;
    ;This does nothing at the moment&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10916</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10916"/>
		<updated>2012-11-09T05:45:55Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* While ... WEnd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $var&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
 Do&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 	If $c = 2 Then ExitLoop&lt;br /&gt;
 Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MySimplestUDF()&lt;br /&gt;
    ;This does nothing at the moment&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10915</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10915"/>
		<updated>2012-11-09T05:44:57Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* For ... Next */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 For $i = 1 to 10 Step 2; in a For..Next loop, the For variable is automatically declared locally&lt;br /&gt;
     ConsoleWrite($i &amp;amp; @LF)&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
 Do&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 	If $c = 2 Then ExitLoop&lt;br /&gt;
 Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MySimplestUDF()&lt;br /&gt;
    ;This does nothing at the moment&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10914</id>
		<title>User:FlutterShy</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10914"/>
		<updated>2012-11-09T05:18:36Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  The editor has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &amp;quot;SciTE Config&amp;quot; under the &amp;quot;tools&amp;quot; menu.  With SciTEConfig a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default Au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s tools menu.  Also available are calltips, abbreviations, and quick access to the helpfile. To access the helpfile the user may press Alt + F1. To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the F1 key to bring up the help file on a relevant page.&lt;br /&gt;
&lt;br /&gt;
==Advanced==&lt;br /&gt;
&lt;br /&gt;
For AutoIt related SciTE help, use the key combination [CTRL] + [F1] to bring up a help file detailing  SciTE related help documentation.&lt;br /&gt;
&lt;br /&gt;
For anyone not familiar with SciTE, here are a few tips and tricks to help you easily modify the installation to suit your needs. For any &amp;quot;truly&amp;quot; advanced info, you should visit the [[http://www.scintilla.org/SciTEDoc.html SciTE home page]].&lt;br /&gt;
&lt;br /&gt;
With the information below, you will be doing some minor editing to SciTEs configuration files.&lt;br /&gt;
It is imperative that you know the hierarchy of SciTEs configuration files. The three main files we will be dealing with here are listed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039;, located in SciTE&#039;s installation directory, usually under &#039;&#039;&#039;[Drive]:\Program Files\AutoIt3\SciTE\&#039;&#039;&#039;.&lt;br /&gt;
* &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;, located in current users profile or &amp;quot;user profile directory&amp;quot;.&lt;br /&gt;
* &#039;&#039;&#039;SciTE.properties&#039;&#039;&#039;, user created file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEGlobal.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;This is the config file you should not mess with. This file has most of the stock setting shipped with SciTE4AutoIt3.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTEUser.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;This is the recommended config file to use. All settings added to this file will override and existing settings in the &amp;quot;SciTEGlobal.properties&amp;quot; file.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;SciTE.properties&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;This is a local project file, all settings in this file only apply to scripts inside this files directory and sub-directories.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;If you&#039;re having any trouble finding any of the previously mentioned file, I would recommend you NOT continue with this information...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Inline Errors===&lt;br /&gt;
[[File:InlineError.JPG‎‎|200px|thumb|right|Intentional error prone code used to display the &amp;quot;Inline Error&amp;quot; feature.]]&lt;br /&gt;
In the latest version of SciTE, there exists a new feature called &amp;quot;Inline Errors&amp;quot;, some users find them annoying. Inline Error marks are error messages that will appear in the source code within the Scintilla window. While helpful, some users prefer to disable this feature often for unknown reasons.&lt;br /&gt;
You can quickly disable/enable them using the &#039;&#039;&#039;SciTEUser.properties&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Open the SciTE user properties file in a text editor and add the following code to the file.&lt;br /&gt;
&lt;br /&gt;
To disable Inline Errors, add the following.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
To enable Inline Errors, add the following.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Display settings for inline errors on the source&lt;br /&gt;
error.inline=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More Language Highlighting Option===&lt;br /&gt;
&lt;br /&gt;
In the SciTEUser.properties file, add the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# Language Highlighting Options&lt;br /&gt;
menu.language=\&lt;br /&gt;
#FreeBasic|bas||\&lt;br /&gt;
Text|txt|Shift+F11|\&lt;br /&gt;
#Ada|ads||\&lt;br /&gt;
AutoIt3|au3|Shift+F12|\&lt;br /&gt;
#Apache Confi&amp;amp;g|conf||\&lt;br /&gt;
#Assembler|asm||\&lt;br /&gt;
#ASN.1|asn1||\&lt;br /&gt;
#Avenue|ave||\&lt;br /&gt;
#Baan|bc||\&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
#Bullant|ant||\&lt;br /&gt;
#&amp;amp;C / C++|cpp||\&lt;br /&gt;
#CMake|cmake||\&lt;br /&gt;
#C&amp;amp;#|cs||\&lt;br /&gt;
#COBOL|cob||\&lt;br /&gt;
#Csound|orc||\&lt;br /&gt;
#CSS|css||\&lt;br /&gt;
#D|d||\&lt;br /&gt;
#&amp;amp;Difference|diff||\&lt;br /&gt;
#&amp;amp;Eiffel|e||\&lt;br /&gt;
#Erlang|erl||\&lt;br /&gt;
#&amp;amp;Errorlist|err||\&lt;br /&gt;
#FlagShip|prg||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#&amp;amp;Fortran|f90||\&lt;br /&gt;
#Gap|g||\&lt;br /&gt;
#Haskell|hs||\&lt;br /&gt;
#H&amp;amp;ypertext|html|$(keyHTML)|\&lt;br /&gt;
#&amp;amp;InnoSetup|iss||\&lt;br /&gt;
#&amp;amp;Java|java||\&lt;br /&gt;
#Java&amp;amp;Script|js||\&lt;br /&gt;
#&amp;amp;Kix|kix||\&lt;br /&gt;
#Lisp|lisp||\&lt;br /&gt;
#Lot|lot||\&lt;br /&gt;
#Lout|lt||\&lt;br /&gt;
#Lu&amp;amp;a|lua||\&lt;br /&gt;
#Matlab|m.matlab||\&lt;br /&gt;
#&amp;amp;Makefile|mak||\&lt;br /&gt;
#MetaPost|mp||\&lt;br /&gt;
#MMIXAL|mms||\&lt;br /&gt;
#Modula-3|m3||\&lt;br /&gt;
#&amp;amp;nnCron crontab|tab||\&lt;br /&gt;
#NSIS|nsis||\&lt;br /&gt;
#Objective Caml|ml||\&lt;br /&gt;
#Octave|m.octave||\&lt;br /&gt;
#Opal|impl||\&lt;br /&gt;
#Pascal|pas||\&lt;br /&gt;
#Pe&amp;amp;rl|pl||\&lt;br /&gt;
#P&amp;amp;HP|php||\&lt;br /&gt;
#P&amp;amp;LSQL|spec||\&lt;br /&gt;
#P&amp;amp;ostScript|ps||\&lt;br /&gt;
#P&amp;amp;OV-Ray SDL|pov||\&lt;br /&gt;
#PowerShell|ps1||\&lt;br /&gt;
#PowerPro|powerpro||\&lt;br /&gt;
#&amp;amp;Properties|properties||\&lt;br /&gt;
#Pytho&amp;amp;n|py||\&lt;br /&gt;
#R|R||\&lt;br /&gt;
#Reso&amp;amp;urce|rc||\&lt;br /&gt;
#Ruby|rb||\&lt;br /&gt;
#Shell|sh||\&lt;br /&gt;
#S&amp;amp;QL|sql||\&lt;br /&gt;
#Specman|e||\&lt;br /&gt;
#&amp;amp;TCL|tcl||\&lt;br /&gt;
#TeX|tex||\&lt;br /&gt;
#&amp;amp;txt2tags|t2t||\&lt;br /&gt;
#&amp;amp;VB|vb||\&lt;br /&gt;
#VBScr&amp;amp;ipt|vbs||\&lt;br /&gt;
#Verilog|v||\&lt;br /&gt;
#VHDL|vhd||\&lt;br /&gt;
#&amp;amp;XML|xml||\&lt;br /&gt;
#&amp;amp;YAML|yaml||&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For whatever language you wish to have an option appear under the &#039;&#039;Language&#039;&#039; menu option, uncomment the language.&lt;br /&gt;
&lt;br /&gt;
Say you want to SciTE to give you the option to highlight batch script code, change the following string in the above list from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
&amp;amp;Batch|bat||\&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Restart SciTE and if done correctly, the option should be present!&lt;br /&gt;
Do this for any language listed in the above example list.&lt;br /&gt;
&lt;br /&gt;
In the case that you uncommented a language and you notice that it&#039;s not being highlighted correctly, then we will have to edit some things in the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;&#039;SciTEGlobal.properties&#039;&#039;&#039; file in a text editor and find the section&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
# import properties\all the language specific properties files&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Below that section there will be a few strings that look like&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;properties&amp;quot;&amp;gt;&lt;br /&gt;
#import properties\[syntax]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Uncomment the syntax related property you wish to have support for.&lt;br /&gt;
&lt;br /&gt;
Say you wanted support for ruby, just locate the one that says &#039;&#039;ruby&#039;&#039; where &#039;&#039;[syntax]&#039;&#039; is written.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=File:InlineError.JPG&amp;diff=10913</id>
		<title>File:InlineError.JPG</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=File:InlineError.JPG&amp;diff=10913"/>
		<updated>2012-11-09T04:30:34Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10912</id>
		<title>User:FlutterShy</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10912"/>
		<updated>2012-11-09T03:16:17Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  The editor has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
==Feature Notes==&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &amp;quot;SciTE Config&amp;quot; under the &amp;quot;tools&amp;quot; menu.  With SciTEConfig a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default Au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s tools menu.  Also available are calltips, abbreviations, and quick access to the helpfile. To access the helpfile the user may press Alt + F1. To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the F1 key to bring up the help file on a relevant page.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10911</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10911"/>
		<updated>2012-11-09T03:12:51Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  The editor has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
==Feature Notes==&lt;br /&gt;
SciTE4AutoIt3 comes with an array of tools and advanced options including a configuration program named &amp;quot;SciTE Config&amp;quot; under the &amp;quot;tools&amp;quot; menu.  With SciTEConfig a user may change the color scheme of SciTE&#039;s syntax highlighting, change the default Au3 script file double-click action, create a script backup policy and determine what tools are shown in SciTE&#039;s tools menu.  Also available are calltips, abbreviations, and quick access to the helpfile. To access the helpfile the user may press Alt + F1. To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the F1 key to bring up the help file on a relevant page.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=An_Introduction_to_Computer_Science_with_AutoIt&amp;diff=10910</id>
		<title>An Introduction to Computer Science with AutoIt</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=An_Introduction_to_Computer_Science_with_AutoIt&amp;diff=10910"/>
		<updated>2012-11-09T01:56:59Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* What is computer science? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Before starting this series, it is assumed you have a firm grasp of programming in the AutoIt language, and a firm grasp on general aspects of computers.During this series, I will attempt to augment your programming knowledge with an informed understanding of some elements of computer science. I will show you a practical and efficient approach to solving computational and implementational problems, as well as provide you with a range of common algorithms and methodologies that will enrich your programming.So lets get started …&lt;br /&gt;
&lt;br /&gt;
== What is computer science? ==&lt;br /&gt;
&lt;br /&gt;
Wikipedia says:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;Computer science is the scientific and practical approach to computation and its applications....&lt;br /&gt;
A computer scientist specializes in the design of computation systems.&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
As such, computer science has two elements:&lt;br /&gt;
* Approach to problem solving&lt;br /&gt;
* Theoretical understanding&lt;br /&gt;
&lt;br /&gt;
During this series, I will focus on both of these objectives, and present them in such a way that they can be used to inform your programming. I will try and keep the theory component to only what is required, to avoid creeping out the less mathy readers with all the abstraction. That said, it is important to remember that the theory is important; and abstracting in this way will broaden your ability to think, reason, and solve computational problems.&lt;br /&gt;
&lt;br /&gt;
== Computer Science :: A Practical Approach ==&lt;br /&gt;
&lt;br /&gt;
If you asked a computer scientist and an ordinary programmer to come up with a solution to the same problem, you would likely get two entirely different pieces of code. These variations are drawn from the considerations each individual have, and the process at which they arrive at their solutions.&lt;br /&gt;
&lt;br /&gt;
A typical programmer&#039;s considerations:&lt;br /&gt;
# A clean, working solution&lt;br /&gt;
# good code readability&lt;br /&gt;
A computer scientists&#039; considerations:&lt;br /&gt;
# A working solution, with known limitations&lt;br /&gt;
# Efficiency / Scalability&lt;br /&gt;
# code readability&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this way, the problem solving process can be broken down into a few distinct phases:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Understand the problem. No really.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A key element of time is spent stepping through and investigating the properties of the problem. Only by doing this, is it possible to realise the limitations of any specific solution, and have epiphanies where you realise new optimizations that greatly improve the efficiency of your solution.For example, consider the task is to write a function that finds the n-th number of the Fibonacci sequence.&lt;br /&gt;
&lt;br /&gt;
The Fibonacci sequence looks something like: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 …&lt;br /&gt;
&lt;br /&gt;
The n-th number in the sequence is dependent on the sum of the two numbers before it.&lt;br /&gt;
&lt;br /&gt;
Knowing this, a typical programmer might write a function like this:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
Func Fib($n)&lt;br /&gt;
	if $n = 0 return 0&lt;br /&gt;
	if $n = 1 return 1&lt;br /&gt;
	return fib(n-1) + fib(n-2)&lt;br /&gt;
Endfunc&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the function is called, it repeatedly calls itself to find the previous two Fibonacci numbers, which in turn call the function again, and so on. (a technique known as recursion).However, a computer scientist will investigate the nature of the problem. For instance, he may find that  a solution like the one above, when given any value for n, needlessly repeats calculations it has already done previously:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
fib(5)&lt;br /&gt;
1. fib(4) + fib(3)&lt;br /&gt;
2. (fib(3) + fib(2)) + (fib(2) + fib(1))&lt;br /&gt;
3. ((fib(2) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1))&lt;br /&gt;
4. (((fib(1) + fib(0)) + fib(1)) + (fib(1) + fib(0))) + ((fib(1) + fib(0)) + fib(1))&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And the computer scientist would use this understanding to his advantage when coming up with a solution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Evaluating solutions based on efficiency / scalability&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Before solutions can be evaluated, one needs a benchmark on which to evaluate them on, which brings us to complexity theory. If you excuse the fancy name, complexity is really just a rough measurement of the speed and efficiency of some solution/algorithm.&lt;br /&gt;
&lt;br /&gt;
Normally, one talks about time complexity, ie the fast your solution is, but memory complexity may also be a consideration.&lt;br /&gt;
&lt;br /&gt;
The measurements are in reference to n. n is some number that represents the input to our program. So under different problems and algorithms, n can be the number of elements in an array, the number of input, the nth number that we are trying to find....etc.&lt;br /&gt;
&lt;br /&gt;
There are three ways of looking at complexity; best case, average case, and worst case scenario. Lets look at an example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
For $x in $array[0]&lt;br /&gt;
	if $array[$x] = $val return $x&lt;br /&gt;
Next&lt;br /&gt;
return $notfound&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the worst case, the element we are searching for is not in the array. Thus, it must search through every element in the array to find a result. Thus, we say it has a worst case time complexity of n, where n is the number of items in the array.&lt;br /&gt;
&lt;br /&gt;
The shorthand for writing worst-case is called big-o notation, and it is written like this: O(n).&lt;br /&gt;
&lt;br /&gt;
If we were to graph y=n, you would find a straight line. Thus, we can say the performance of this solution is directly proportional to the number of elements in the array. This is a good thing, as it means that performance does not degrade at an increasing rate for large values of n.&lt;br /&gt;
&lt;br /&gt;
In the best case scenario, the element we are looking for is in the first element of the array, so complexity is o(1) ie: it only ever takes one iteration. Notice that the little o is used for notation in this case.&lt;br /&gt;
&lt;br /&gt;
I leave it to an exercise to the reader to determine what the average case time complexity is. Θ (???)&lt;br /&gt;
&lt;br /&gt;
In computer science, we are almost always only concerned about the worst-case scenario, and the shape of the graph if we plot y=timecomplexity where x=n. For instance, O(n^2) looks like this:&lt;br /&gt;
&lt;br /&gt;
http://sqlinthewild.co.za/wp-content/uploads/2011/11/On2_thumb.png&lt;br /&gt;
&lt;br /&gt;
By the shape of the graph, it is clear that it takes an increasing amount of time per value of n, as n becomes large. Thus, it is clear that this algorithm doesnt scale well for large values of n.&lt;br /&gt;
&lt;br /&gt;
Additionally, when writing the notation for complexity, we only care about the highest power of n. Say you had some function that had O(44n + 4n^2 + 88), you would write it as O(n^2), as all other terms become insignificant as n gets really large. Moreover, as we are only concerned about the shape of the graph, we can drop the numbers before the n.&lt;br /&gt;
&lt;br /&gt;
In this way, you should evaluate the efficiency of your potential solutions, and be able to project how the solution will behave when heavily loaded (ie: large values for n). You should then pick one which is the best balance of complexity, and ease of implementation.A large part of this series will be detailing how to implement various algorithms, which have varying complexities. Often, there will be many possible choices, and you will need to pick the one best for you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Pick, implement, and test your solution&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The final stage of development. Going back to our Fibonacci function example, our computer scientist may decide to store the results of calculations (like answer of fib(2)) to stop unnessessary recursion and repeated calculations. This is a technique known as dynamic programming, and it greatly improves the complexity of this algorithm, and works really fast for large values of n.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This concludes part one of this series. In the next part, [[An Introduction to Computer Science with AutoIt pt2]], we start to go through comventional algorithms / solutions to sorting, and in future parts, move on to datastructures, and searching algorithms.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=FAQ&amp;diff=10909</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=FAQ&amp;diff=10909"/>
		<updated>2012-11-09T01:43:44Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* _Singleton function */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a list of frequently asked questions asked on the forums.&lt;br /&gt;
Other FAQs include:&lt;br /&gt;
* The one found in the [http://www.autoitscript.com/autoit3/docs/faq.htm AutoIt HelpFile].  Much of it is about the transition from V2 to V3, but most is still relevant and should be a port of call, as well as this one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I debug my script?==&lt;br /&gt;
&lt;br /&gt;
=== In SciTE ===&lt;br /&gt;
This one has a myriad of answers, but the most effective is to begin by using the [http://www.autoitscript.com/autoit3/scite/ SciTE4AutoIt3 Editor] to create or edit scripts. This program is useful in debugging for the following reasons:&lt;br /&gt;
&lt;br /&gt;
* Syntax highlighting allows for immediate viewing of any mistakes from unended script tags or quotes. This allows the scripter to visibly see the difference between the following portions of code.&lt;br /&gt;
[[File:FAQ_Q1_2.jpg|center|Incorrect code]]&lt;br /&gt;
And the incorrect version: &lt;br /&gt;
[[File:FAQ_Q1_3.jpg|center||Correct Code]]&lt;br /&gt;
* Global Syntax check built directly into the tools menu allows you to check an entire script for problems all at once.&lt;br /&gt;
* Built-in code tidying program that correctly indents untidy code and repairs messy scripts to allow them to be more readable. It also corrects problems with incorrectly capitalised function names and variables.&lt;br /&gt;
* Per-line trace insertion allows you to log every line of code executed to debug errors.&lt;br /&gt;
* Debug MsgBox&#039;s or ConsoleWrite&#039;s are able to be added anywhere in the script directly from SciTE. ConsoleWrite lines are less intrusive and prevent the added annoyance to the user of MsgBox&#039;s.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_4.jpg|center|Picture of SciTE4AutoIt3]]&lt;br /&gt;
&lt;br /&gt;
=== Using more code to check @error value ===&lt;br /&gt;
Nearly all functions will return something.  Most of the time when a function fails, it returns 0 and sets @error.  You can use this information not only to create scripts that handle for different errors but to debug and find out exactly why you are having problems.  Check the help file for specific functions and their return values.&lt;br /&gt;
&lt;br /&gt;
=== Via the Tray icon===&lt;br /&gt;
You can add this line at the top of your script (1 is on, 0 is off) to enable debugging from the tray icon.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;AutoItSetOption (&amp;quot;TrayIconDebug&amp;quot;, 1);0-off&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then if you run the script (uncompiled as an AU3 file), you can mouse over the AutoIt icon in the system tray (down by the clock) to display debugging information.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_1.jpg|center|Example output for TrayIconDebug]]&lt;br /&gt;
&lt;br /&gt;
=== OutputDebugString native call ===&lt;br /&gt;
You can also debug a script on any computer by adding the following code to your script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;Func dbg($msg)&lt;br /&gt;
	 DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;none&amp;quot;, &amp;quot;OutputDebugString&amp;quot;, &amp;quot;str&amp;quot;, $msg)&lt;br /&gt;
 EndFunc&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then, when you need to add a debug line, call it as necessary. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;dbg(&amp;quot;The value of Variable 1 at this time is &amp;quot; &amp;amp; $var1)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This debugging is completely transparent to the user, and is only viewable with a program such as DebugView from SysInternals. This method of debugging has the added advantage of being available to the developer in situations where is not acceptable or feasable to install SciTE on a client&#039;s unit.&lt;br /&gt;
&lt;br /&gt;
=== Graphical debugger ===&lt;br /&gt;
Stumpii created a [http://www.autoitscript.com/forum/index.php?showtopic=21834 Graphical AutoIt Debugger], similar to Dev-C++&#039;s debugging style.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_5.jpg|center|Stumpii&#039;s Graphical AutoIt Debugger]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run something that is not an exe file [.txt, .msi, .pdf,.jpg etc.] [or] How can I open a webpage in the default browser?==&lt;br /&gt;
It was for this reason that the ShellExecute function was created. Here is one example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\autoitscripts\test.au3&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;edit&amp;quot;, @SW_MAXIMIZE)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also specify a web address this way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;http://www.autoitscript.com/forum&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;open&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you normally are able to right-click the file and select print, then you can also print the file from AutoIt using this function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\boot.ini&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;print&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to open the file with the default program, you can do as follows (BETA ONLY):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\autoitscripts\test.au3&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish your script to wait until the process is finished, you can use the ShellExecuteWait function with the same parameters.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
The default verb is the verb configured in the registry. If no verb is set as default in the registry then the &amp;quot;open&amp;quot; verb is used. If the &amp;quot;open&amp;quot; verb is not present then the first verb listed in the registry is used (except on Windows 2000).&lt;br /&gt;
&lt;br /&gt;
==How can I prevent more than one copy of my script from running at once / detect another copy of my script running?==&lt;br /&gt;
&lt;br /&gt;
=== _Singleton function ===&lt;br /&gt;
There are a few different ways to go about this. You can use a function called _Singleton to detect multiple instances of your script. An example of how to use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
_Singleton(&amp;quot;TheNameOfMyScript&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this instance, the script will bring up some messages explaining to the user of the occurring events. &lt;br /&gt;
This example will show you how the above function can be used in a real world application.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
If _Singleton(&amp;quot;MyScriptName&amp;quot;, 1) = 0 Then&lt;br /&gt;
    ; If successful, running our script a second time should cause us to fall through here&lt;br /&gt;
    MsgBox(16, &amp;quot;User Generated Error Message&amp;quot;, &amp;quot;Error: This script is already running!&amp;quot;)&lt;br /&gt;
Else&lt;br /&gt;
    ; We have detected that we are the only instance running, now we will run a second instance to display _Singleton&#039;s function!&lt;br /&gt;
    MsgBox(64, &amp;quot;Information!&amp;quot;, &amp;quot;We are the first instance of this script, press OK to run another instance and trigger the error message!&amp;quot;)&lt;br /&gt;
    Switch @Compiled&lt;br /&gt;
        Case 1&lt;br /&gt;
            Run(FileGetShortName(@ScriptFullPath));when running an app, it&#039;s usually better to use its short name&lt;br /&gt;
        Case 0&lt;br /&gt;
            Run(FileGetShortName(@AutoItExe) &amp;amp; &#039; /AutoIt3ExecuteScript &#039; &amp;amp; FileGetShortName(@ScriptFullPath))&lt;br /&gt;
    EndSwitch&lt;br /&gt;
    Sleep(1000)&lt;br /&gt;
    MsgBox(64, &amp;quot;Information!&amp;quot;, &amp;quot;We ran a second instance, you should have recieved an error message!&amp;quot;, 5)&lt;br /&gt;
EndIf&lt;br /&gt;
Exit&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===_MutexExists function ===&lt;br /&gt;
Another method is to use _MutexExists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If _MutexExists(&amp;quot;MydeswswScriptName&amp;quot;) Then&lt;br /&gt;
	; We know the script is already running. Let the user know.&lt;br /&gt;
	MsgBox(0, &amp;quot;Script Name&amp;quot;, &amp;quot;This script is already running. Using multiple copies of this script at the same time is unsupported!&amp;quot;)&lt;br /&gt;
	Exit&lt;br /&gt;
EndIf&lt;br /&gt;
&lt;br /&gt;
;Function Author- Martin&lt;br /&gt;
Func _MutexExists($sOccurenceName)&lt;br /&gt;
	Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError&lt;br /&gt;
	$sOccurenceName = StringReplace($sOccurenceName, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;); to avoid error&lt;br /&gt;
	$handle = DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;CreateMutex&amp;quot;, &amp;quot;int&amp;quot;, 0, &amp;quot;long&amp;quot;, 1, &amp;quot;str&amp;quot;, $sOccurenceName)&lt;br /&gt;
	$lastError = DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetLastError&amp;quot;)&lt;br /&gt;
	Return $lastError[0] = $ERROR_ALREADY_EXISTS&lt;br /&gt;
EndFunc;==&amp;gt;_MutexExists&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run my script as a service?==&lt;br /&gt;
This is also a question with multiple answers, and none of them are the only way to do it. The first question to ask yourself is whether or not you wish to install the service on other computers besides your own.&lt;br /&gt;
&lt;br /&gt;
=== On your own computer - One time only ===&lt;br /&gt;
The easiest way to do this is to use Pirmasoft RunAsSvc. This program makes services easy to install and easy to remove when necessary.&lt;br /&gt;
&lt;br /&gt;
=== On all computers that run your script===&lt;br /&gt;
To do this you can use SRVANY.EXE and [http://www.autoitscript.com/forum/index.php?showtopic=6487 ServiceControl.au3]. You can then use this code to install your script as a service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;ServiceControl.au3&amp;quot;&lt;br /&gt;
$servicename = &amp;quot;MyServiceName&amp;quot;&lt;br /&gt;
_CreateService(&amp;quot;&amp;quot;, $servicename, &amp;quot;My AutoIt Script&amp;quot;, &amp;quot;C:\Path_to_\srvany.exe&amp;quot;, &amp;quot;LocalSystem&amp;quot;, &amp;quot;&amp;quot;, 0x110)&lt;br /&gt;
RegWrite(&amp;quot;HKLM\SYSTEM\CurrentControlSet\Services\&amp;quot; &amp;amp; $servicename &amp;amp; &amp;quot;\Parameters&amp;quot;, &amp;quot;Application&amp;quot;, &amp;quot;REG_SZ&amp;quot;, @ScriptFullPath)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use the following code to delete this service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;ServiceControl.au3&amp;quot;&lt;br /&gt;
$servicename = &amp;quot;MyServiceName&amp;quot;&lt;br /&gt;
_DeleteService(&amp;quot;&amp;quot;, $servicename)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one caveat to setting up AutoIt as a service. If the service is not installed using the above code, it must have the &amp;quot;allow service to interact with the desktop&amp;quot; setting or else automation functions such as Control* or Win* functions will not function. To assure the service does indeed have this setting, use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;RegWrite(&amp;quot;HKLM\SYSTEM\CurrentControlSet\Services\[ServiceName]&amp;quot;, &amp;quot;Type&amp;quot;, &amp;quot;REG_DWORD&amp;quot;, 0x110)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I create/start/stop or otherwise control a service?==&lt;br /&gt;
There are two include libraries that are designed specifically to interact with services. These are the following:&lt;br /&gt;
&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=6487 ServiceControl.au3] made by SumTingWong. Functionality:&lt;br /&gt;
** _StartService()&lt;br /&gt;
** _StopService()&lt;br /&gt;
** _ServiceExists()&lt;br /&gt;
** _ServiceRunning()&lt;br /&gt;
** _CreateService()&lt;br /&gt;
** _DeleteService()&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=22165 _NTServices.au3] made by CatchFish. Functionality:&lt;br /&gt;
** _ServiceStart()&lt;br /&gt;
** _ServiceStop()&lt;br /&gt;
** _ServiceStatus()&lt;br /&gt;
** _ServicePause()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I display a progress bar while copying files or directories?==&lt;br /&gt;
There are a many different topics on how to do this.  For more, just search the forums for [http://www.autoitscript.com/forum/index.php?act=Search&amp;amp;CODE=show&amp;amp;searchid=22030d4d4effe5e32da23fdb69ed772f&amp;amp;search_in=posts&amp;amp;result_type=topics&amp;amp;highlite=%2BCopy%2B Progress Copy + Progress].&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=11313 Copy with progress dialog]... By ezztabi&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=11888 Yet another copy with progress]... By SumTingWong&lt;br /&gt;
* [http://www.autoit.de/index.php?page=Thread&amp;amp;postID=58875 _MultiFileCopy]... By Oscar (German Forums)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=19370&amp;amp;st=45&amp;amp;p=186198&amp;amp;#entry186198 _FileCopy]... By Jos&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q6_1.jpg|center|Copy progress dialog by ezztabi]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make a hotkey that only works in my GUI?==&lt;br /&gt;
It used to be quite tedious setting hotkeys to only work in your GUI.  Now there is an easier way with the function GUISetAccelerators.&lt;br /&gt;
&lt;br /&gt;
(From Helpfile example)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; A simple custom messagebox that uses the MessageLoop mode&lt;br /&gt;
#include &amp;lt;GUIConstantsEx.au3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GUICreate(&amp;quot;Custom Msgbox&amp;quot;, 210, 80)&lt;br /&gt;
&lt;br /&gt;
GUICtrlCreateLabel(&amp;quot;Please click a button!&amp;quot;, 10, 10)&lt;br /&gt;
$YesID = GUICtrlCreateButton(&amp;quot;Yes&amp;quot;, 10, 50, 50, 20)&lt;br /&gt;
$NoID = GUICtrlCreateButton(&amp;quot;No&amp;quot;, 80, 50, 50, 20)&lt;br /&gt;
$ExitID = GUICtrlCreateButton(&amp;quot;Exit&amp;quot;, 150, 50, 50, 20)&lt;br /&gt;
&lt;br /&gt;
; Set accelerators for Ctrl+y and Ctrl+n&lt;br /&gt;
Dim $AccelKeys[2][2]=[[&amp;quot;^y&amp;quot;, $YesID], [&amp;quot;^n&amp;quot;, $NoID]]&lt;br /&gt;
GUISetAccelerators($AccelKeys)&lt;br /&gt;
&lt;br /&gt;
GUISetState(); display the GUI&lt;br /&gt;
&lt;br /&gt;
Do&lt;br /&gt;
	$msg = GUIGetMsg()&lt;br /&gt;
&lt;br /&gt;
	Select&lt;br /&gt;
		Case $msg = $YesID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Yes&amp;quot;)&lt;br /&gt;
		Case $msg = $NoID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;No&amp;quot;)&lt;br /&gt;
		Case $msg = $ExitID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Exit&amp;quot;)&lt;br /&gt;
		Case $msg = $GUI_EVENT_CLOSE&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Close&amp;quot;)&lt;br /&gt;
	EndSelect&lt;br /&gt;
Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I perform an action while a key is held down?==&lt;br /&gt;
You can use the _IsPressed() function to determine when a key is held down. The values that can be specified in this function are listed in the AutoIt Help File under User Defined Functions -&amp;gt; Misc Management -&amp;gt; _IsPressed. The following example will press the left mouse button while the k key is held down.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
$pressed = 0&lt;br /&gt;
While 1&lt;br /&gt;
	If _IsPressed(&amp;quot;4B&amp;quot;) Then&lt;br /&gt;
		If Not $pressed Then&lt;br /&gt;
			ToolTip(&amp;quot;K Key being held down&amp;quot;)&lt;br /&gt;
			MouseDown(&amp;quot;left&amp;quot;)&lt;br /&gt;
			$pressed = 1&lt;br /&gt;
		EndIf&lt;br /&gt;
	Else&lt;br /&gt;
		If $pressed Then&lt;br /&gt;
			ToolTip(&amp;quot;&amp;quot;)&lt;br /&gt;
			MouseUp(&amp;quot;left&amp;quot;)&lt;br /&gt;
			$pressed = 0&lt;br /&gt;
		EndIf&lt;br /&gt;
	EndIf&lt;br /&gt;
	Sleep(250)&lt;br /&gt;
WEnd&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run my script on a remote computer over the network?==&lt;br /&gt;
The answer to this question depends on how much experience you have in networking. If the target system is a Windows 2000 or Windows XP Pro system to which you have administrator access then you may use one of the following programs:&lt;br /&gt;
&lt;br /&gt;
* PsExec from SysInternals&lt;br /&gt;
* BeyondExec from BeyondLogic&lt;br /&gt;
&lt;br /&gt;
With either of these programs it is possible to launch any process on a remote system and even copy your script to the target computer before starting it. Neither these programs nor any others will work with Windows XP Home Edition unless you create a custom &amp;quot;command listener&amp;quot; that you manually install on the target system.&lt;br /&gt;
&lt;br /&gt;
NOTE: Those of you with more advanced programming skills and a little imagination can figure out how to use the service control libraries and srvany.exe to do this same thing without either of the above mentioned programs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make a User Defined Function with optional parameters like the ones I see in the Help File?==&lt;br /&gt;
You can specify optional parameters by giving them a default value in the Func declaration. An example of how this is &lt;br /&gt;
&lt;br /&gt;
done:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func testme($param1, $param2 = &amp;quot;nothing&amp;quot;, $param3 = 5)&lt;br /&gt;
	MsgBox(0, &amp;quot;&amp;quot;, &amp;quot;Parameter one is required. The value of Parameter 1 is &amp;quot; &amp;amp; $param1 &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Parameter 2 is optional. The value of Parameter 2 is &amp;quot; &amp;amp; $param2 &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Parameter 3 is optional. The value of Parameter 3 is &amp;quot; &amp;amp; $param3)&lt;br /&gt;
EndFunc&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If testme() is called with only one parameter [I.E. testme(&amp;quot;test&amp;quot;)] then the output is:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Parameter one is required. The value of Parameter 1 is test&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 2 is optional. The value of Parameter 2 is nothing&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 3 is optional. The value of Parameter 3 is 5&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
However, if the function is called with more than one parameter like this testme(&amp;quot;test&amp;quot;, &amp;quot;something&amp;quot;), then the output is&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Parameter one is required. The value of Parameter 1 is test&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 2 is optional. The value of Parameter 2 is something&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 3 is optional. The value of Parameter 3 is 5&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make my script start every time windows starts?==&lt;br /&gt;
You can use one of the following codes to allow your script to start with Windows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;RegWrite(&amp;quot;HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run&amp;quot;, &amp;quot;MyProgramName&amp;quot;, &amp;quot;REG_SZ&amp;quot;, @ScriptFullPath)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;FileCreateShortcut(@ScriptFullPath, @StartupCommonDir &amp;amp; &amp;quot;\MyProgramName.lnk&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I have the script delete itself?==&lt;br /&gt;
The following function will delete the running script or .exe once it has finished execution.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: Make a copy of your script before calling this function!!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func _SelfDelete($iDelay = 0)&lt;br /&gt;
	Local $sCmdFile&lt;br /&gt;
	FileDelete(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;)&lt;br /&gt;
	$sCmdFile = &#039;ping -n &#039; &amp;amp; $iDelay &amp;amp; &#039; 127.0.0.1 &amp;gt; nul&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;:loop&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;del &amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot;&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;if exist &amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot; goto loop&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;del %0&#039;&lt;br /&gt;
	FileWrite(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;, $sCmdFile)&lt;br /&gt;
	Run(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;, @TempDir, @SW_HIDE)&lt;br /&gt;
EndFunc;==&amp;gt;_SelfDelete&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How can I create a clickable website hyperlink in my gui?==&lt;br /&gt;
[[File:FAQ_Q13_1.jpg|center|Example GUI using Gary&#039;s UDF.]]&lt;br /&gt;
&lt;br /&gt;
Gary Frost has made great advances in this area and has provided a [http://www.autoitscript.com/forum/index.php?showtopic=23111&amp;amp;st=0 UDF here] to help with doing this.&lt;br /&gt;
&lt;br /&gt;
==How can I change the screen resolution / refresh rate / color depth?==&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=20121 ChangeResolution.au3] is a library function created to make changes to these settings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get the screen resolution in multiple monitor setups?==&lt;br /&gt;
The following code was worked out by Larry to determine the total screen resolution of multiple monitors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$aTSR = _GetTotalScreenResolution()&lt;br /&gt;
MsgBox(0, &amp;quot;Total Screen Resolution&amp;quot;, &amp;quot;Width = &amp;quot; &amp;amp; $aTSR[0] &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Height = &amp;quot; &amp;amp; $aTSR[1])&lt;br /&gt;
&lt;br /&gt;
;Original code by Larry.&lt;br /&gt;
;Edited by BrettF&lt;br /&gt;
Func _GetTotalScreenResolution()&lt;br /&gt;
	Local $aRet[2]&lt;br /&gt;
	Global Const $SM_VIRTUALWIDTH = 78&lt;br /&gt;
	Global Const $SM_VIRTUALHEIGHT = 79&lt;br /&gt;
	$VirtualDesktopWidth = DllCall(&amp;quot;user32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetSystemMetrics&amp;quot;, &amp;quot;int&amp;quot;, $SM_VIRTUALWIDTH)&lt;br /&gt;
	$aRet[0] = $VirtualDesktopWidth[0]&lt;br /&gt;
	$VirtualDesktopHeight = DllCall(&amp;quot;user32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetSystemMetrics&amp;quot;, &amp;quot;int&amp;quot;, $SM_VIRTUALHEIGHT)&lt;br /&gt;
	$aRet[1] = $VirtualDesktopHeight[0]&lt;br /&gt;
	Return $aRet&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How can I register a file type with my program [or] How can I make files with a certain extension open in my program?==&lt;br /&gt;
[[File:FAQ_Q16_1.jpg|center|Example of how a file type can be registered.]]&lt;br /&gt;
File registration can be a tricky business for those who have not done it before. The first thing to be done is to modify your script to allow it to accept files from the command line. Here is one example of how to do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;$cmdline[0] is the number of parameters passed&lt;br /&gt;
If $cmdline[0] &amp;lt;&amp;gt; 0 Then&lt;br /&gt;
	$filename = $cmdline[1]&lt;br /&gt;
;Do something with the file here&lt;br /&gt;
	MsgBox(0, &amp;quot;UXYFixer&amp;quot;, &#039;The file name passed to the command line is &amp;quot;&#039; &amp;amp; $filename &amp;amp; &#039;&amp;quot;&#039;)&lt;br /&gt;
Else&lt;br /&gt;
; We did not get any command line parameters.&lt;br /&gt;
; If this is a command line only program, you would want to&lt;br /&gt;
; alert the user that the command line parameters were incorrect.&lt;br /&gt;
; If this is a GUI program (like a notepad program), you would&lt;br /&gt;
; want to simply continue from here without opening a file.&lt;br /&gt;
	MsgBox(0, &amp;quot;UXYFixer&amp;quot;, &#039;Command line parameters incorrect.&#039; &amp;amp; @CRLF &amp;amp; &#039;Command line usage: &amp;quot;&#039; &amp;amp; @ScriptName &amp;amp; &#039;&amp;quot; &amp;quot;file to process&amp;quot;&#039;)&lt;br /&gt;
 EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After your script is ready to accept files, you can begin to register the file type you need with your program. To prevent errors, this-is-me has created a UDF that will allow you to do this easily:&lt;br /&gt;
&lt;br /&gt;
Here is an example of how to register and unregister a file extension using this UDF:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;quot;FileRegister.au3&amp;quot;&lt;br /&gt;
;================================================&lt;br /&gt;
;&lt;br /&gt;
; Description:	FileRegister($ext, $cmd, $verb [, $def [, $icon = &amp;quot;&amp;quot; [, $desc = &amp;quot;&amp;quot; ]]])&lt;br /&gt;
;			   Registers a file type in Explorer&lt;br /&gt;
;&lt;br /&gt;
; Parameter(s): $ext -  File Extension without period eg. &amp;quot;zip&amp;quot;&lt;br /&gt;
;		$cmd -  Program path with arguments eg. &#039;&amp;quot;C:\test\testprog.exe&amp;quot; &amp;quot;%1&amp;quot;&#039;&lt;br /&gt;
;			 (%1 is 1st argument, %2 is 2nd, etc.)&lt;br /&gt;
;		$verb - Name of action to perform on file&lt;br /&gt;
;			 eg. &amp;quot;Open with ProgramName&amp;quot; or &amp;quot;Extract Files&amp;quot;&lt;br /&gt;
;		$def -  Action is the default action for this filetype&lt;br /&gt;
;			 (1 for true 0 for false)&lt;br /&gt;
;			 If the file is not already associated, this will be the default.&lt;br /&gt;
;		$icon - Default icon for filetype including resource # if needed&lt;br /&gt;
;			 eg. &amp;quot;C:\test\testprog.exe,0&amp;quot; or &amp;quot;C:\test\filetype.ico&amp;quot;&lt;br /&gt;
;		$desc - File Description eg. &amp;quot;Zip File&amp;quot; or &amp;quot;ProgramName Document&amp;quot;&lt;br /&gt;
;&lt;br /&gt;
;================================================&lt;br /&gt;
&lt;br /&gt;
 FileRegister(&amp;quot;uxy&amp;quot;, &#039;&amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot; &amp;quot;%1&amp;quot;&#039;, &amp;quot;Open in UXYFixer&amp;quot;, 1, @ScriptFullPath &amp;amp; &#039;,0&#039;, &amp;quot;UXYFixer Document&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
;========================================&lt;br /&gt;
;&lt;br /&gt;
; Description:	FileUnRegister($ext, $verb)&lt;br /&gt;
;			   UnRegisters a verb for a file type in Explorer&lt;br /&gt;
; Parameter(s):  $ext - File Extension without period eg. &amp;quot;zip&amp;quot;&lt;br /&gt;
;			   $verb - Name of file action to remove&lt;br /&gt;
;					 eg. &amp;quot;Open with ProgramName&amp;quot; or &amp;quot;Extract Files&amp;quot;&lt;br /&gt;
;&lt;br /&gt;
;========================================&lt;br /&gt;
&lt;br /&gt;
 FileUnRegister(&amp;quot;uxy&amp;quot;, &amp;quot;Open in UXYFixer&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download here:&#039;&#039;&#039;&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?app=core&amp;amp;module=attach&amp;amp;section=attach&amp;amp;attach_id=26378 FileRegister.au3]&lt;br /&gt;
&lt;br /&gt;
==Why doesn&#039;t my combobox (GUICtrlCreateCombo) show a dropdown list when clicked?==&lt;br /&gt;
When using GUICtrlCreateCombo be sure to enter the desired height for your combobox list in the &amp;quot;height&amp;quot; parameter. Windows XP automatically selects an appropriate height for combo boxes, but other versions of Windows usually do not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$combo = GUICtrlCreateCombo(&amp;quot;&amp;quot;,10,10,200,20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Would correctly be changed to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$combo = GUICtrlCreateCombo(&amp;quot;&amp;quot;,10,10,200,200)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why isn&#039;t my thread getting any replies?==&lt;br /&gt;
&lt;br /&gt;
=== Asking the right question right ===&lt;br /&gt;
Did you give a good description of the problem? If your title or explanation of the issue is not descriptive, users are likely to bypass your issue instead of helping. Post titles such as &amp;quot;Help Me&amp;quot;, &amp;quot;I Have A Problem&amp;quot;, &amp;quot;Question&amp;quot;, &amp;quot;Help me fix my code&amp;quot;, &amp;quot;This code doesn&#039;t work&amp;quot; or similarly worded titles will not readily draw forum users to your post. Experienced users (which are your best hope of resolving the issue) will often skip your post altogether in cases like this. An example of a post title descriptive enough to attract users to assist you is &amp;quot;Problem with WinWaitClose&amp;quot; or &amp;quot;Loop never ends&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example for reproduction ===&lt;br /&gt;
Did you post example code? If you have not posted an example of the code you are having an issue with, then you will not recieve support. When posting a non-working script, please do so in the smallest amount of stand-alone code possible. If the code you post cannot run by itself on another person&#039;s computer, they will not be able to recreate the issue.&lt;br /&gt;
&lt;br /&gt;
=== Speak English and speak it right ===&lt;br /&gt;
Did you use proper English? Here are guidelines for posting properly in the english language:&lt;br /&gt;
* Use proper case.  THIS IS CONSIDERED YELLING. If you post in ALL UPPERCASE or all lowercase then you will look like a doofus.&lt;br /&gt;
* Use proper punctuation. Complete sentences need only one trailing punctuation mark -- not three!!! Writing a sentance without simple punctuation such as commas or other punctuation is considered lazy, which is considered a good judge of the poster&#039;s coding style. If you cannot summon the strength to write a sentence with correct punctuation, you will most likely miss simple coding mistakes such as unterminated quotes.&lt;br /&gt;
&lt;br /&gt;
=== Breaking forum rules, law, modesty, or common Sense ===&lt;br /&gt;
Make sure you are not giving the impression of breaking forum rules, http://www.autoitscript.com/forum/forum-2/announcement-15-forum-rules-7-nov-2012/. Make sure you are not doing anything that can be perceived as breaking the law.&lt;br /&gt;
&lt;br /&gt;
==Why does the Ctrl key get stuck down after I run my script?==&lt;br /&gt;
&lt;br /&gt;
=== Keys virtually stuck ===&lt;br /&gt;
It could equally be the Shift Or the Alt key.&lt;br /&gt;
&lt;br /&gt;
If you use Send In a script And you have a problem With keys being stuck down Then Send is the most likely culprit. A similar problem can occur With BlockInput. The solution is generally quite simple. If there is a key like Shift Or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes Then the key will get &#039;stuck&#039; down. As an example of a solution, you could replace the Send function in your script with the _SendEx function below.&lt;br /&gt;
&lt;br /&gt;
The _SendEx function waits for the Shift, Alt And Ctrl keys to be released or pops up a warning if the $warn parameter is not an empty string. Therefore it is not intended to be used when one of these modifier keys has been set to be down using any combination of {ALTDOWN}, {SHIFTDOWN} and {ALTDOWN}.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt; Misc.au3 &amp;gt;&lt;br /&gt;
;Send the string $ss after the Shift Alt and Ctrl keys are released. Optionally give a warning after 1 sec if any of those keys are still down.&lt;br /&gt;
;Requires misc.au3 to be included in the script for the _IsPressed function.&lt;br /&gt;
Func _SendEx($ss, $warn = &amp;quot;&amp;quot;)&lt;br /&gt;
	Local $iT = TimerInit()&lt;br /&gt;
&lt;br /&gt;
	While _IsPressed(&amp;quot;10&amp;quot;) Or _IsPressed(&amp;quot;11&amp;quot;) Or _IsPressed(&amp;quot;12&amp;quot;)&lt;br /&gt;
		If $warn &amp;lt;&amp;gt; &amp;quot;&amp;quot; And TimerDiff($iT) &amp;gt; 1000 Then&lt;br /&gt;
			MsgBox(262144, &amp;quot;Warning&amp;quot;, $warn)&lt;br /&gt;
		EndIf&lt;br /&gt;
		Sleep(50)&lt;br /&gt;
	WEnd&lt;br /&gt;
	Send($ss)&lt;br /&gt;
EndFunc;==&amp;gt;_SendEx&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== General unstuck method ===&lt;br /&gt;
Shilbiz also discovered that the following can &#039;clear&#039; locked down keys.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt; ControlSend(&amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;text&amp;quot;, 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I use Pixel functions?==&lt;br /&gt;
&lt;br /&gt;
=== Using a color change as an event ===&lt;br /&gt;
The following is an example of using the pixel to check if the colour has changed in a specific region.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $PixelCheck, $NewCheck&lt;br /&gt;
$PixelCheck = PixelCheckSum(40, 50, 60, 70); Get the checksum for this area.&lt;br /&gt;
While 1; Keep going&lt;br /&gt;
	$NewCheck = PixelCheckSum(40, 50, 60, 70)&lt;br /&gt;
	If $PixelCheck &amp;lt;&amp;gt; $NewCheck Then&lt;br /&gt;
		; The old pixel checksum and the new one are different.&lt;br /&gt;
		$PixelCheck = $NewCheck; Update the $PixelCheck to the new value&lt;br /&gt;
		; Let us now it has changed.  Change this to what you want to happen when the colour in the region changes.&lt;br /&gt;
		Msgbox(48,&amp;quot;PixelChecksum&amp;quot;,&amp;quot;Pixel region has changed !&amp;quot;)&lt;br /&gt;
	EndIf&lt;br /&gt;
	Sleep(50); Just to give the CPU a bit of a break.&lt;br /&gt;
Wend&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Searching for a specific pixel color ===&lt;br /&gt;
This is an example of searching for a specific pixel (red), both pure red (0xFF0000) and red in a few different shades.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;; Find a pure red pixel in the range 0,0-20,300&lt;br /&gt;
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )&lt;br /&gt;
If Not @error Then&lt;br /&gt;
	MsgBox(0, &amp;quot;X and Y are:&amp;quot;, $coord[0] &amp;amp; &amp;quot;,&amp;quot; &amp;amp; $coord[1])&lt;br /&gt;
EndIf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Find a pure red pixel or a red pixel within 10 shades variations of pure red&lt;br /&gt;
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000, 10 )&lt;br /&gt;
If Not @error Then&lt;br /&gt;
	MsgBox(0, &amp;quot;X and Y are:&amp;quot;, $coord[0] &amp;amp; &amp;quot;,&amp;quot; &amp;amp; $coord[1])&lt;br /&gt;
EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why doesn&#039;t my script work on a locked workstation?==&lt;br /&gt;
On a locked station any window will never be active (active is only dialog with text &amp;quot;Press Ctrl+Alt+Del&amp;quot;).  In Windows locked state applications run hidden (behind that visible dialog) and do not have focus and active status.  So generally don&#039;t use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.  Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.  This way you may have your script resistive against another active windows.  It&#039;s possible to run such a script from scheduler on locked Windows stations.&lt;br /&gt;
&lt;br /&gt;
==Where can I learn AutoIt? Are there any tutorials?==&lt;br /&gt;
To learn AutoIt you have two main options available to you:&lt;br /&gt;
&lt;br /&gt;
AutoIt 1-2-3, an interactive classroom by Valuater. You may find it here:&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=21048 http://www.autoitscript.com/forum/index.php?showtopic=21048]&lt;br /&gt;
&lt;br /&gt;
There is also updated LxP&#039;s AutoIt tutorial by BrettF. You can find it here:&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=84960 http://www.autoitscript.com/forum/index.php?showtopic=84960]&lt;br /&gt;
&lt;br /&gt;
There is also a book; AutoIt v3: Your Quick Guide by Andy Flessner.&lt;br /&gt;
You can buy the book from here:&lt;br /&gt;
[http://oreilly.com/catalog/9780596515126/ http://oreilly.com/catalog/9780596515126/]&lt;br /&gt;
&lt;br /&gt;
On YouTube there are many videos available:&lt;br /&gt;
[http://www.youtube.com/results?search_query=autoit+tutorial&amp;amp;search_type=&amp;amp;aq=0&amp;amp;oq=AutoIt http://www.youtube.com/results?search_query=autoit+tutorial&amp;amp;search_type=&amp;amp;aq=0&amp;amp;oq=AutoIt]&lt;br /&gt;
&lt;br /&gt;
==Why does my script no longer decompile?==&lt;br /&gt;
Decompilation is no longer supported, and is only available for the older versions of AutoIt (Version 3.2.5.1 and earlier compiled scripts).&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;do not&#039;&#039;&#039; post on this topic, but search the forums for more information.  Posting topics like this will usually get the topic locked.&lt;br /&gt;
&lt;br /&gt;
Also posting the source (if a hacked decompiler was used) of other compiled scripts, or otherwise mentioning these hacked decompilers will probably get you banned.  It is also in violation of the AutoIt EULA (End-User-License-Agreement).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;You may not reverse engineer or disassemble the SOFTWARE PRODUCT or compiled scripts that were created with the SOFTWARE PRODUCT.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please see the [[Decompiling FAQ]] for more information.&lt;br /&gt;
&lt;br /&gt;
==How can I get a window handle when all I have is a PID?==&lt;br /&gt;
Refer to the following example showing converting and use when manipulating the window. The function is based on work by Smoke_N/Hubertus and Helge.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;;Run process&lt;br /&gt;
$iPID = Run(&amp;quot;Notepad.exe&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
;Allow window to initialize...&lt;br /&gt;
Sleep (500)&lt;br /&gt;
&lt;br /&gt;
;Get HWND.&lt;br /&gt;
$hWnd = _GetHwndFromPID($iPID)&lt;br /&gt;
&lt;br /&gt;
;Maximize&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_MAXIMIZE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Minimize&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_MINIMIZE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Restore window&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_RESTORE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Move top left corner of screen, and resize to 800x600&lt;br /&gt;
WinMove($hWnd, &amp;quot;&amp;quot;, 0, 0, 800, 600)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Calculate Center of screen.&lt;br /&gt;
$x = (@DesktopWidth / 2) - 400; Desktop width divided by 2, then minus half the width of the window&lt;br /&gt;
$y = (@DesktopHeight / 2) - 300; Desktop height divided by 2, then minus half the height of the window&lt;br /&gt;
&lt;br /&gt;
;Move to center of screen&lt;br /&gt;
WinMove($hWnd, &amp;quot;&amp;quot;, $x, $y)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Close notepad&lt;br /&gt;
WinClose($hWnd)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Function for getting HWND from PID&lt;br /&gt;
Func _GetHwndFromPID($PID)&lt;br /&gt;
	$hWnd = 0&lt;br /&gt;
	$winlist = WinList()&lt;br /&gt;
	Do&lt;br /&gt;
		For $i = 1 To $winlist[0][0]&lt;br /&gt;
			If $winlist[$i][0] &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;
				$iPID2 = WinGetProcess($winlist[$i][1])&lt;br /&gt;
				If $iPID2 = $PID Then&lt;br /&gt;
					$hWnd = $winlist[$i][1]&lt;br /&gt;
					ExitLoop&lt;br /&gt;
				EndIf&lt;br /&gt;
			EndIf&lt;br /&gt;
		Next&lt;br /&gt;
	Until $hWnd &amp;lt;&amp;gt; 0&lt;br /&gt;
	Return $hWnd&lt;br /&gt;
EndFunc;==&amp;gt;_GetHwndFromPID&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I use single or double quotes in strings?==&lt;br /&gt;
It is a fairly simple concept once you get the basics down.  Basically there are a few different ways to go about mixing quotes in strings.&lt;br /&gt;
&lt;br /&gt;
A string in AutoIt can be encased in either single(&#039;) or double (&amp;quot;) quotes.  So if you want to add only one type of quote into your string, your first port of call is to use the other type of quote to encase the string.  Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$var = &amp;quot;I am a &#039;quote&#039; inside the string&amp;quot;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&lt;br /&gt;
$var = &#039;I wish I could be a &amp;quot;quote&amp;quot; inside the string!&#039;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have to have both types of quotes in the string, the easiest way is to escape the quote ending the string as so to speak.  To do this, use two quotes instead of one.  Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$var = &#039;I am a single &#039;&#039;quote&#039;&#039; inside the string made using &amp;quot;single quote!&amp;quot;&#039;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==When should I bump my threads?==&lt;br /&gt;
As a courtesy to other users you should only bump your post once in a 24 hour period.  Doing this allows all users the chance to get helped equally.  Also refer to [http://www.autoitscript.com/forum/index.php?showtopic=95704&amp;amp;view=findpost&amp;amp;p=688050 Why isn&#039;t my thread getting any replies?], as this will help you get replies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I protect my code from decompilation?==&lt;br /&gt;
The fact of the matter is &#039;&#039;&#039;you can&#039;t fully protect your code&#039;&#039;&#039;.  AutoIt is an  interpreted language, so all scripts are interpreted, and that script has to get stored somewhere.  There is still hope though.  You can take certain measures to prevent decompiled code from being usable to the person that decompiled.  The first step is to obfuscate your code.  This causes the code to become unreadable.  Basically variables and functions are renamed, making it very hard to make head or tail of what is what.&lt;br /&gt;
&lt;br /&gt;
Please see the [[Decompiling FAQ]] for more information.&lt;br /&gt;
&lt;br /&gt;
==How can I decompile my AutoIt EXEs?==&lt;br /&gt;
You cannot decompile your AutoIt compiled scripts unless it was compiled with AutoIt 3.2.5.1 or earlier.&lt;br /&gt;
&lt;br /&gt;
If you wish to simulate decompilation for your script, you can do this using the following simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;;Original Author SmokeN&lt;br /&gt;
If $CMDLINE[0] Then&lt;br /&gt;
	If $CMDLINE[1] == &amp;quot;/SOURCE&amp;quot; AND $CMDLINE[2] == &amp;quot;MYPASSWORD&amp;quot; Then&lt;br /&gt;
		FileInstall(&amp;quot;ThisSCript.au3&amp;quot;, @ScriptDir &amp;amp; &amp;quot;\DecompiledScript.au3&amp;quot;)&lt;br /&gt;
	EndIf&lt;br /&gt;
EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then if you run the exe with the following command line parameters your source will be installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;myscript.exe /SOURCE MYPASSWORD&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is proper forum etiquette?  What rules are there for the forum?==&lt;br /&gt;
Proper forum etiquette will ensure you will stay a member of these forums.  So try to follow these rules.  Also see this [http://www.autoitscript.com/forum/index.php?showtopic=95704&amp;amp;st=15&amp;amp;p=688050&amp;amp;#entry688050 FAQ post], as you should follow what is outlined there as well.&lt;br /&gt;
&lt;br /&gt;
* Use proper English.  MSN speak and the like makes it very hard to understand what you want.  Keep posts in proper case because UPPERCASE is considered yelling and lowercase makes you look stupid.  Don&#039;t use more punctuation marks than necessary. For example ?!!!? and ????? is completely unnecessary.&lt;br /&gt;
* Before posting help with a script, make sure you follow these steps:&lt;br /&gt;
*# Search for your issue.&lt;br /&gt;
*#* There are many thousands of posts on this forum, and chances are your question has been asked before.  Make sure to use a variety of terms to maximize your results.&lt;br /&gt;
*# Read the helpfile&lt;br /&gt;
*#* Most if not all things in the help file will have an example (native functions) or two.  Give them a go to try see how the functions work.  Most of the time it helps!&lt;br /&gt;
*# Give it a go&lt;br /&gt;
*#* Seriously, if you can&#039;t be bothered to give it a go, then why should we be bothered to help you?  If you feel you can&#039;t do it and you don&#039;t try then how will you ever know?  We always prefer that you give it a go because you can learn from your mistakes and hopefully understand it better.&lt;br /&gt;
*# Post your problem&lt;br /&gt;
*#* Make sure you post in the correct forum.&lt;br /&gt;
*#** AutoIt Specific&lt;br /&gt;
*#*** General Help and Support (Most support questions)&lt;br /&gt;
*#*** GUI Support (Support for the Graphical User Interface)&lt;br /&gt;
*#** Non-AutoIT&lt;br /&gt;
*#*** Chat&lt;br /&gt;
*#*** Developer Chat (Usually for C++ questions.)&lt;br /&gt;
*#* Include a detailed description in the content of the post, and a detailed title&lt;br /&gt;
*#** Titles such as &#039;Help&#039; and &#039;What&#039;s wrong?&#039; are not acceptable.  To get the most help with your problem, be as descriptive as you can in the title, but keep in mind your title cannot be too long.&lt;br /&gt;
*#** Make sure you also include a descriptive question.  Just saying &#039;what is wrong with the following&#039; is also not acceptable, as we will have no idea what the problem is.  Describe what you think is wrong and what is not working.  It makes our job easier.&lt;br /&gt;
*#* Always include your code&lt;br /&gt;
*#** It shows us that you have tried and gives us a head start with something to play with.&lt;br /&gt;
* Usually asking for a script is not taken too well, within reason.  Keep in mind that this is a support forum, so please acknowledge that.   Most of us would rather that you learn rather than just having a script written for you.  If you do need something written for you, maybe try  [http://www.rentacoder.com/ RentACoder], as they are more suited to requests.&lt;br /&gt;
* Don&#039;t PM other members asking for them to look at threads of to help you unless they request it.  It is actually quite rude and annoying to receive PMs of that nature.&lt;br /&gt;
* Lurk a little before you dive right in. Read a number of posts, or check out the group&#039;s archives. Get a feel for the tone of the forum so you can participate accordingly.&lt;br /&gt;
* Say online exactly what you would say in person. In other words, if you wouldn&#039;t say it to the person&#039;s face in front of your Grandmother, you shouldn&#039;t type it here.&lt;br /&gt;
* Remember your face doesn&#039;t show. Words alone can convey sentiment, but without benefit of inflection or facial expression, they can be misconstrued. Use descriptive wording, emoticons or .gifs to ensure your meaning is clear. By the same token, don&#039;t jump to conclusions about another person&#039;s intent in posting an unclear comment. When in doubt, ask for clarification.&lt;br /&gt;
* Be respectful. Internet etiquette is similar to standard etiquette in this area. Appreciate that your opinion is one of many. You can disagree with another person without being disrespectful or rude to other people.&lt;br /&gt;
* Ignore Trolls. If you engage in conversation with one, you&#039;ll raise your blood pressure and empower the troll. You can&#039;t win a flame war, and you can&#039;t sway a troll&#039;s opinion. Often, they don&#039;t even care about the subject.  They live for the conflict and nothing more. Trolls are common and not worthy of your time. Ignore their posts no matter how inflammatory and eventually they&#039;ll get bored and move on.&lt;br /&gt;
* When you have found an answer for your question:&lt;br /&gt;
*# Do not edit your post to be blank or to have worthless information.  People may be searching for the same issue you have, so be courteous to them by leaving your question there.&lt;br /&gt;
*# It is also optional to add the likes of [SOLVED] into the title, and redirecting people to the answer that helped you.  It can make the lives of people searching easier.&lt;br /&gt;
* Finally follow the rules:&lt;br /&gt;
** [http://www.autoitscript.com/forum/forum-6/announcement-13-forum-rules/ Forum rules]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=54168 Rules for the Chat forum]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=65889 Rules for asking for source code]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=37739 General policies and forum settings]&lt;br /&gt;
&lt;br /&gt;
Some general points taken from [http://www.ehow.com/how_2106033_use-proper-forum-etiquette.html here].&lt;br /&gt;
&lt;br /&gt;
==Are there forums available in my local language?==&lt;br /&gt;
Yes there are some available.  Some forum members here participate in multiple forums.&lt;br /&gt;
* [http://www.autoit.de/ German Forums]&lt;br /&gt;
* [http://www.autoit.fr/  French Forums]&lt;br /&gt;
* [http://www.autoit.es/ Spanish Forums]&lt;br /&gt;
* [http://autoit-script.ru/ Russian Forums]&lt;br /&gt;
&lt;br /&gt;
Please note that these are independent, community-run message boards and not just a translation of this board.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=FAQ&amp;diff=10907</id>
		<title>FAQ</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=FAQ&amp;diff=10907"/>
		<updated>2012-11-09T01:24:51Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* _Singleton function */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a list of frequently asked questions asked on the forums.&lt;br /&gt;
Other FAQs include:&lt;br /&gt;
* The one found in the [http://www.autoitscript.com/autoit3/docs/faq.htm AutoIt HelpFile].  Much of it is about the transition from V2 to V3, but most is still relevant and should be a port of call, as well as this one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I debug my script?==&lt;br /&gt;
&lt;br /&gt;
=== In SciTE ===&lt;br /&gt;
This one has a myriad of answers, but the most effective is to begin by using the [http://www.autoitscript.com/autoit3/scite/ SciTE4AutoIt3 Editor] to create or edit scripts. This program is useful in debugging for the following reasons:&lt;br /&gt;
&lt;br /&gt;
* Syntax highlighting allows for immediate viewing of any mistakes from unended script tags or quotes. This allows the scripter to visibly see the difference between the following portions of code.&lt;br /&gt;
[[File:FAQ_Q1_2.jpg|center|Incorrect code]]&lt;br /&gt;
And the incorrect version: &lt;br /&gt;
[[File:FAQ_Q1_3.jpg|center||Correct Code]]&lt;br /&gt;
* Global Syntax check built directly into the tools menu allows you to check an entire script for problems all at once.&lt;br /&gt;
* Built-in code tidying program that correctly indents untidy code and repairs messy scripts to allow them to be more readable. It also corrects problems with incorrectly capitalised function names and variables.&lt;br /&gt;
* Per-line trace insertion allows you to log every line of code executed to debug errors.&lt;br /&gt;
* Debug MsgBox&#039;s or ConsoleWrite&#039;s are able to be added anywhere in the script directly from SciTE. ConsoleWrite lines are less intrusive and prevent the added annoyance to the user of MsgBox&#039;s.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_4.jpg|center|Picture of SciTE4AutoIt3]]&lt;br /&gt;
&lt;br /&gt;
=== Using more code to check @error value ===&lt;br /&gt;
Nearly all functions will return something.  Most of the time when a function fails, it returns 0 and sets @error.  You can use this information not only to create scripts that handle for different errors but to debug and find out exactly why you are having problems.  Check the help file for specific functions and their return values.&lt;br /&gt;
&lt;br /&gt;
=== Via the Tray icon===&lt;br /&gt;
You can add this line at the top of your script (1 is on, 0 is off) to enable debugging from the tray icon.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;AutoItSetOption (&amp;quot;TrayIconDebug&amp;quot;, 1);0-off&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then if you run the script (uncompiled as an AU3 file), you can mouse over the AutoIt icon in the system tray (down by the clock) to display debugging information.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_1.jpg|center|Example output for TrayIconDebug]]&lt;br /&gt;
&lt;br /&gt;
=== OutputDebugString native call ===&lt;br /&gt;
You can also debug a script on any computer by adding the following code to your script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;Func dbg($msg)&lt;br /&gt;
	 DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;none&amp;quot;, &amp;quot;OutputDebugString&amp;quot;, &amp;quot;str&amp;quot;, $msg)&lt;br /&gt;
 EndFunc&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then, when you need to add a debug line, call it as necessary. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;dbg(&amp;quot;The value of Variable 1 at this time is &amp;quot; &amp;amp; $var1)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This debugging is completely transparent to the user, and is only viewable with a program such as DebugView from SysInternals. This method of debugging has the added advantage of being available to the developer in situations where is not acceptable or feasable to install SciTE on a client&#039;s unit.&lt;br /&gt;
&lt;br /&gt;
=== Graphical debugger ===&lt;br /&gt;
Stumpii created a [http://www.autoitscript.com/forum/index.php?showtopic=21834 Graphical AutoIt Debugger], similar to Dev-C++&#039;s debugging style.&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q1_5.jpg|center|Stumpii&#039;s Graphical AutoIt Debugger]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run something that is not an exe file [.txt, .msi, .pdf,.jpg etc.] [or] How can I open a webpage in the default browser?==&lt;br /&gt;
It was for this reason that the ShellExecute function was created. Here is one example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\autoitscripts\test.au3&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;edit&amp;quot;, @SW_MAXIMIZE)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also specify a web address this way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;http://www.autoitscript.com/forum&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;open&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you normally are able to right-click the file and select print, then you can also print the file from AutoIt using this function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\boot.ini&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;print&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish to open the file with the default program, you can do as follows (BETA ONLY):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;ShellExecute(&amp;quot;C:\autoitscripts\test.au3&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you wish your script to wait until the process is finished, you can use the ShellExecuteWait function with the same parameters.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
The default verb is the verb configured in the registry. If no verb is set as default in the registry then the &amp;quot;open&amp;quot; verb is used. If the &amp;quot;open&amp;quot; verb is not present then the first verb listed in the registry is used (except on Windows 2000).&lt;br /&gt;
&lt;br /&gt;
==How can I prevent more than one copy of my script from running at once / detect another copy of my script running?==&lt;br /&gt;
&lt;br /&gt;
=== _Singleton function ===&lt;br /&gt;
There are a few different ways to go about this. You can use a function called _Singleton to detect multiple instances of your script. An example of how to use this code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
_Singleton(&amp;quot;TheNameOfMyScript&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this instance, the script will immediately exit if there is already one copy running. If you simply want to know if another copy is running, you can use code similar to the next example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
If _Singleton(&amp;quot;MyScriptName&amp;quot;, 1) = 0 Then&lt;br /&gt;
	; We know the script is already running. Let the user know.&lt;br /&gt;
	MsgBox(0, &amp;quot;Script Name&amp;quot;, &amp;quot;This script is already running. Using multiple copies of this script at the same time is unsupported!&amp;quot;)&lt;br /&gt;
	Exit&lt;br /&gt;
EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===_MutexExists function ===&lt;br /&gt;
Another method is to use _MutexExists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If _MutexExists(&amp;quot;MydeswswScriptName&amp;quot;) Then&lt;br /&gt;
	; We know the script is already running. Let the user know.&lt;br /&gt;
	MsgBox(0, &amp;quot;Script Name&amp;quot;, &amp;quot;This script is already running. Using multiple copies of this script at the same time is unsupported!&amp;quot;)&lt;br /&gt;
	Exit&lt;br /&gt;
EndIf&lt;br /&gt;
&lt;br /&gt;
;Function Author- Martin&lt;br /&gt;
Func _MutexExists($sOccurenceName)&lt;br /&gt;
	Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError&lt;br /&gt;
	$sOccurenceName = StringReplace($sOccurenceName, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;); to avoid error&lt;br /&gt;
	$handle = DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;CreateMutex&amp;quot;, &amp;quot;int&amp;quot;, 0, &amp;quot;long&amp;quot;, 1, &amp;quot;str&amp;quot;, $sOccurenceName)&lt;br /&gt;
	$lastError = DllCall(&amp;quot;kernel32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetLastError&amp;quot;)&lt;br /&gt;
	Return $lastError[0] = $ERROR_ALREADY_EXISTS&lt;br /&gt;
EndFunc;==&amp;gt;_MutexExists&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run my script as a service?==&lt;br /&gt;
This is also a question with multiple answers, and none of them are the only way to do it. The first question to ask yourself is whether or not you wish to install the service on other computers besides your own.&lt;br /&gt;
&lt;br /&gt;
=== On your own computer - One time only ===&lt;br /&gt;
The easiest way to do this is to use Pirmasoft RunAsSvc. This program makes services easy to install and easy to remove when necessary.&lt;br /&gt;
&lt;br /&gt;
=== On all computers that run your script===&lt;br /&gt;
To do this you can use SRVANY.EXE and [http://www.autoitscript.com/forum/index.php?showtopic=6487 ServiceControl.au3]. You can then use this code to install your script as a service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;ServiceControl.au3&amp;quot;&lt;br /&gt;
$servicename = &amp;quot;MyServiceName&amp;quot;&lt;br /&gt;
_CreateService(&amp;quot;&amp;quot;, $servicename, &amp;quot;My AutoIt Script&amp;quot;, &amp;quot;C:\Path_to_\srvany.exe&amp;quot;, &amp;quot;LocalSystem&amp;quot;, &amp;quot;&amp;quot;, 0x110)&lt;br /&gt;
RegWrite(&amp;quot;HKLM\SYSTEM\CurrentControlSet\Services\&amp;quot; &amp;amp; $servicename &amp;amp; &amp;quot;\Parameters&amp;quot;, &amp;quot;Application&amp;quot;, &amp;quot;REG_SZ&amp;quot;, @ScriptFullPath)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or use the following code to delete this service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;ServiceControl.au3&amp;quot;&lt;br /&gt;
$servicename = &amp;quot;MyServiceName&amp;quot;&lt;br /&gt;
_DeleteService(&amp;quot;&amp;quot;, $servicename)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There is one caveat to setting up AutoIt as a service. If the service is not installed using the above code, it must have the &amp;quot;allow service to interact with the desktop&amp;quot; setting or else automation functions such as Control* or Win* functions will not function. To assure the service does indeed have this setting, use the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;RegWrite(&amp;quot;HKLM\SYSTEM\CurrentControlSet\Services\[ServiceName]&amp;quot;, &amp;quot;Type&amp;quot;, &amp;quot;REG_DWORD&amp;quot;, 0x110)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I create/start/stop or otherwise control a service?==&lt;br /&gt;
There are two include libraries that are designed specifically to interact with services. These are the following:&lt;br /&gt;
&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=6487 ServiceControl.au3] made by SumTingWong. Functionality:&lt;br /&gt;
** _StartService()&lt;br /&gt;
** _StopService()&lt;br /&gt;
** _ServiceExists()&lt;br /&gt;
** _ServiceRunning()&lt;br /&gt;
** _CreateService()&lt;br /&gt;
** _DeleteService()&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=22165 _NTServices.au3] made by CatchFish. Functionality:&lt;br /&gt;
** _ServiceStart()&lt;br /&gt;
** _ServiceStop()&lt;br /&gt;
** _ServiceStatus()&lt;br /&gt;
** _ServicePause()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I display a progress bar while copying files or directories?==&lt;br /&gt;
There are a many different topics on how to do this.  For more, just search the forums for [http://www.autoitscript.com/forum/index.php?act=Search&amp;amp;CODE=show&amp;amp;searchid=22030d4d4effe5e32da23fdb69ed772f&amp;amp;search_in=posts&amp;amp;result_type=topics&amp;amp;highlite=%2BCopy%2B Progress Copy + Progress].&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=11313 Copy with progress dialog]... By ezztabi&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=11888 Yet another copy with progress]... By SumTingWong&lt;br /&gt;
* [http://www.autoit.de/index.php?page=Thread&amp;amp;postID=58875 _MultiFileCopy]... By Oscar (German Forums)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=19370&amp;amp;st=45&amp;amp;p=186198&amp;amp;#entry186198 _FileCopy]... By Jos&lt;br /&gt;
&lt;br /&gt;
[[File:FAQ_Q6_1.jpg|center|Copy progress dialog by ezztabi]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make a hotkey that only works in my GUI?==&lt;br /&gt;
It used to be quite tedious setting hotkeys to only work in your GUI.  Now there is an easier way with the function GUISetAccelerators.&lt;br /&gt;
&lt;br /&gt;
(From Helpfile example)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; A simple custom messagebox that uses the MessageLoop mode&lt;br /&gt;
#include &amp;lt;GUIConstantsEx.au3&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GUICreate(&amp;quot;Custom Msgbox&amp;quot;, 210, 80)&lt;br /&gt;
&lt;br /&gt;
GUICtrlCreateLabel(&amp;quot;Please click a button!&amp;quot;, 10, 10)&lt;br /&gt;
$YesID = GUICtrlCreateButton(&amp;quot;Yes&amp;quot;, 10, 50, 50, 20)&lt;br /&gt;
$NoID = GUICtrlCreateButton(&amp;quot;No&amp;quot;, 80, 50, 50, 20)&lt;br /&gt;
$ExitID = GUICtrlCreateButton(&amp;quot;Exit&amp;quot;, 150, 50, 50, 20)&lt;br /&gt;
&lt;br /&gt;
; Set accelerators for Ctrl+y and Ctrl+n&lt;br /&gt;
Dim $AccelKeys[2][2]=[[&amp;quot;^y&amp;quot;, $YesID], [&amp;quot;^n&amp;quot;, $NoID]]&lt;br /&gt;
GUISetAccelerators($AccelKeys)&lt;br /&gt;
&lt;br /&gt;
GUISetState(); display the GUI&lt;br /&gt;
&lt;br /&gt;
Do&lt;br /&gt;
	$msg = GUIGetMsg()&lt;br /&gt;
&lt;br /&gt;
	Select&lt;br /&gt;
		Case $msg = $YesID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Yes&amp;quot;)&lt;br /&gt;
		Case $msg = $NoID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;No&amp;quot;)&lt;br /&gt;
		Case $msg = $ExitID&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Exit&amp;quot;)&lt;br /&gt;
		Case $msg = $GUI_EVENT_CLOSE&lt;br /&gt;
			MsgBox(0, &amp;quot;You clicked on&amp;quot;, &amp;quot;Close&amp;quot;)&lt;br /&gt;
	EndSelect&lt;br /&gt;
Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I perform an action while a key is held down?==&lt;br /&gt;
You can use the _IsPressed() function to determine when a key is held down. The values that can be specified in this function are listed in the AutoIt Help File under User Defined Functions -&amp;gt; Misc Management -&amp;gt; _IsPressed. The following example will press the left mouse button while the k key is held down.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;lt;Misc.au3&amp;gt;&lt;br /&gt;
$pressed = 0&lt;br /&gt;
While 1&lt;br /&gt;
	If _IsPressed(&amp;quot;4B&amp;quot;) Then&lt;br /&gt;
		If Not $pressed Then&lt;br /&gt;
			ToolTip(&amp;quot;K Key being held down&amp;quot;)&lt;br /&gt;
			MouseDown(&amp;quot;left&amp;quot;)&lt;br /&gt;
			$pressed = 1&lt;br /&gt;
		EndIf&lt;br /&gt;
	Else&lt;br /&gt;
		If $pressed Then&lt;br /&gt;
			ToolTip(&amp;quot;&amp;quot;)&lt;br /&gt;
			MouseUp(&amp;quot;left&amp;quot;)&lt;br /&gt;
			$pressed = 0&lt;br /&gt;
		EndIf&lt;br /&gt;
	EndIf&lt;br /&gt;
	Sleep(250)&lt;br /&gt;
WEnd&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I run my script on a remote computer over the network?==&lt;br /&gt;
The answer to this question depends on how much experience you have in networking. If the target system is a Windows 2000 or Windows XP Pro system to which you have administrator access then you may use one of the following programs:&lt;br /&gt;
&lt;br /&gt;
* PsExec from SysInternals&lt;br /&gt;
* BeyondExec from BeyondLogic&lt;br /&gt;
&lt;br /&gt;
With either of these programs it is possible to launch any process on a remote system and even copy your script to the target computer before starting it. Neither these programs nor any others will work with Windows XP Home Edition unless you create a custom &amp;quot;command listener&amp;quot; that you manually install on the target system.&lt;br /&gt;
&lt;br /&gt;
NOTE: Those of you with more advanced programming skills and a little imagination can figure out how to use the service control libraries and srvany.exe to do this same thing without either of the above mentioned programs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make a User Defined Function with optional parameters like the ones I see in the Help File?==&lt;br /&gt;
You can specify optional parameters by giving them a default value in the Func declaration. An example of how this is &lt;br /&gt;
&lt;br /&gt;
done:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func testme($param1, $param2 = &amp;quot;nothing&amp;quot;, $param3 = 5)&lt;br /&gt;
	MsgBox(0, &amp;quot;&amp;quot;, &amp;quot;Parameter one is required. The value of Parameter 1 is &amp;quot; &amp;amp; $param1 &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Parameter 2 is optional. The value of Parameter 2 is &amp;quot; &amp;amp; $param2 &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Parameter 3 is optional. The value of Parameter 3 is &amp;quot; &amp;amp; $param3)&lt;br /&gt;
EndFunc&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If testme() is called with only one parameter [I.E. testme(&amp;quot;test&amp;quot;)] then the output is:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Parameter one is required. The value of Parameter 1 is test&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 2 is optional. The value of Parameter 2 is nothing&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 3 is optional. The value of Parameter 3 is 5&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
However, if the function is called with more than one parameter like this testme(&amp;quot;test&amp;quot;, &amp;quot;something&amp;quot;), then the output is&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Parameter one is required. The value of Parameter 1 is test&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 2 is optional. The value of Parameter 2 is something&amp;lt;br /&amp;gt;&lt;br /&gt;
Parameter 3 is optional. The value of Parameter 3 is 5&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I make my script start every time windows starts?==&lt;br /&gt;
You can use one of the following codes to allow your script to start with Windows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;RegWrite(&amp;quot;HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run&amp;quot;, &amp;quot;MyProgramName&amp;quot;, &amp;quot;REG_SZ&amp;quot;, @ScriptFullPath)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;FileCreateShortcut(@ScriptFullPath, @StartupCommonDir &amp;amp; &amp;quot;\MyProgramName.lnk&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I have the script delete itself?==&lt;br /&gt;
The following function will delete the running script or .exe once it has finished execution.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING: Make a copy of your script before calling this function!!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Func _SelfDelete($iDelay = 0)&lt;br /&gt;
	Local $sCmdFile&lt;br /&gt;
	FileDelete(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;)&lt;br /&gt;
	$sCmdFile = &#039;ping -n &#039; &amp;amp; $iDelay &amp;amp; &#039; 127.0.0.1 &amp;gt; nul&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;:loop&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;del &amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot;&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;if exist &amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot; goto loop&#039; &amp;amp; @CRLF _&lt;br /&gt;
			 &amp;amp; &#039;del %0&#039;&lt;br /&gt;
	FileWrite(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;, $sCmdFile)&lt;br /&gt;
	Run(@TempDir &amp;amp; &amp;quot;\scratch.bat&amp;quot;, @TempDir, @SW_HIDE)&lt;br /&gt;
EndFunc;==&amp;gt;_SelfDelete&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==How can I create a clickable website hyperlink in my gui?==&lt;br /&gt;
[[File:FAQ_Q13_1.jpg|center|Example GUI using Gary&#039;s UDF.]]&lt;br /&gt;
&lt;br /&gt;
Gary Frost has made great advances in this area and has provided a [http://www.autoitscript.com/forum/index.php?showtopic=23111&amp;amp;st=0 UDF here] to help with doing this.&lt;br /&gt;
&lt;br /&gt;
==How can I change the screen resolution / refresh rate / color depth?==&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=20121 ChangeResolution.au3] is a library function created to make changes to these settings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How can I get the screen resolution in multiple monitor setups?==&lt;br /&gt;
The following code was worked out by Larry to determine the total screen resolution of multiple monitors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$aTSR = _GetTotalScreenResolution()&lt;br /&gt;
MsgBox(0, &amp;quot;Total Screen Resolution&amp;quot;, &amp;quot;Width = &amp;quot; &amp;amp; $aTSR[0] &amp;amp; @CRLF &amp;amp; _&lt;br /&gt;
		&amp;quot;Height = &amp;quot; &amp;amp; $aTSR[1])&lt;br /&gt;
&lt;br /&gt;
;Original code by Larry.&lt;br /&gt;
;Edited by BrettF&lt;br /&gt;
Func _GetTotalScreenResolution()&lt;br /&gt;
	Local $aRet[2]&lt;br /&gt;
	Global Const $SM_VIRTUALWIDTH = 78&lt;br /&gt;
	Global Const $SM_VIRTUALHEIGHT = 79&lt;br /&gt;
	$VirtualDesktopWidth = DllCall(&amp;quot;user32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetSystemMetrics&amp;quot;, &amp;quot;int&amp;quot;, $SM_VIRTUALWIDTH)&lt;br /&gt;
	$aRet[0] = $VirtualDesktopWidth[0]&lt;br /&gt;
	$VirtualDesktopHeight = DllCall(&amp;quot;user32.dll&amp;quot;, &amp;quot;int&amp;quot;, &amp;quot;GetSystemMetrics&amp;quot;, &amp;quot;int&amp;quot;, $SM_VIRTUALHEIGHT)&lt;br /&gt;
	$aRet[1] = $VirtualDesktopHeight[0]&lt;br /&gt;
	Return $aRet&lt;br /&gt;
EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  How can I register a file type with my program [or] How can I make files with a certain extension open in my program?==&lt;br /&gt;
[[File:FAQ_Q16_1.jpg|center|Example of how a file type can be registered.]]&lt;br /&gt;
File registration can be a tricky business for those who have not done it before. The first thing to be done is to modify your script to allow it to accept files from the command line. Here is one example of how to do this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
;$cmdline[0] is the number of parameters passed&lt;br /&gt;
If $cmdline[0] &amp;lt;&amp;gt; 0 Then&lt;br /&gt;
	$filename = $cmdline[1]&lt;br /&gt;
;Do something with the file here&lt;br /&gt;
	MsgBox(0, &amp;quot;UXYFixer&amp;quot;, &#039;The file name passed to the command line is &amp;quot;&#039; &amp;amp; $filename &amp;amp; &#039;&amp;quot;&#039;)&lt;br /&gt;
Else&lt;br /&gt;
; We did not get any command line parameters.&lt;br /&gt;
; If this is a command line only program, you would want to&lt;br /&gt;
; alert the user that the command line parameters were incorrect.&lt;br /&gt;
; If this is a GUI program (like a notepad program), you would&lt;br /&gt;
; want to simply continue from here without opening a file.&lt;br /&gt;
	MsgBox(0, &amp;quot;UXYFixer&amp;quot;, &#039;Command line parameters incorrect.&#039; &amp;amp; @CRLF &amp;amp; &#039;Command line usage: &amp;quot;&#039; &amp;amp; @ScriptName &amp;amp; &#039;&amp;quot; &amp;quot;file to process&amp;quot;&#039;)&lt;br /&gt;
 EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
After your script is ready to accept files, you can begin to register the file type you need with your program. To prevent errors, this-is-me has created a UDF that will allow you to do this easily:&lt;br /&gt;
&lt;br /&gt;
Here is an example of how to register and unregister a file extension using this UDF:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;#include &amp;quot;FileRegister.au3&amp;quot;&lt;br /&gt;
;================================================&lt;br /&gt;
;&lt;br /&gt;
; Description:	FileRegister($ext, $cmd, $verb [, $def [, $icon = &amp;quot;&amp;quot; [, $desc = &amp;quot;&amp;quot; ]]])&lt;br /&gt;
;			   Registers a file type in Explorer&lt;br /&gt;
;&lt;br /&gt;
; Parameter(s): $ext -  File Extension without period eg. &amp;quot;zip&amp;quot;&lt;br /&gt;
;		$cmd -  Program path with arguments eg. &#039;&amp;quot;C:\test\testprog.exe&amp;quot; &amp;quot;%1&amp;quot;&#039;&lt;br /&gt;
;			 (%1 is 1st argument, %2 is 2nd, etc.)&lt;br /&gt;
;		$verb - Name of action to perform on file&lt;br /&gt;
;			 eg. &amp;quot;Open with ProgramName&amp;quot; or &amp;quot;Extract Files&amp;quot;&lt;br /&gt;
;		$def -  Action is the default action for this filetype&lt;br /&gt;
;			 (1 for true 0 for false)&lt;br /&gt;
;			 If the file is not already associated, this will be the default.&lt;br /&gt;
;		$icon - Default icon for filetype including resource # if needed&lt;br /&gt;
;			 eg. &amp;quot;C:\test\testprog.exe,0&amp;quot; or &amp;quot;C:\test\filetype.ico&amp;quot;&lt;br /&gt;
;		$desc - File Description eg. &amp;quot;Zip File&amp;quot; or &amp;quot;ProgramName Document&amp;quot;&lt;br /&gt;
;&lt;br /&gt;
;================================================&lt;br /&gt;
&lt;br /&gt;
 FileRegister(&amp;quot;uxy&amp;quot;, &#039;&amp;quot;&#039; &amp;amp; @ScriptFullPath &amp;amp; &#039;&amp;quot; &amp;quot;%1&amp;quot;&#039;, &amp;quot;Open in UXYFixer&amp;quot;, 1, @ScriptFullPath &amp;amp; &#039;,0&#039;, &amp;quot;UXYFixer Document&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
;========================================&lt;br /&gt;
;&lt;br /&gt;
; Description:	FileUnRegister($ext, $verb)&lt;br /&gt;
;			   UnRegisters a verb for a file type in Explorer&lt;br /&gt;
; Parameter(s):  $ext - File Extension without period eg. &amp;quot;zip&amp;quot;&lt;br /&gt;
;			   $verb - Name of file action to remove&lt;br /&gt;
;					 eg. &amp;quot;Open with ProgramName&amp;quot; or &amp;quot;Extract Files&amp;quot;&lt;br /&gt;
;&lt;br /&gt;
;========================================&lt;br /&gt;
&lt;br /&gt;
 FileUnRegister(&amp;quot;uxy&amp;quot;, &amp;quot;Open in UXYFixer&amp;quot;)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Download here:&#039;&#039;&#039;&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?app=core&amp;amp;module=attach&amp;amp;section=attach&amp;amp;attach_id=26378 FileRegister.au3]&lt;br /&gt;
&lt;br /&gt;
==Why doesn&#039;t my combobox (GUICtrlCreateCombo) show a dropdown list when clicked?==&lt;br /&gt;
When using GUICtrlCreateCombo be sure to enter the desired height for your combobox list in the &amp;quot;height&amp;quot; parameter. Windows XP automatically selects an appropriate height for combo boxes, but other versions of Windows usually do not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$combo = GUICtrlCreateCombo(&amp;quot;&amp;quot;,10,10,200,20)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Would correctly be changed to:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$combo = GUICtrlCreateCombo(&amp;quot;&amp;quot;,10,10,200,200)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why isn&#039;t my thread getting any replies?==&lt;br /&gt;
&lt;br /&gt;
=== Asking the right question right ===&lt;br /&gt;
Did you give a good description of the problem? If your title or explanation of the issue is not descriptive, users are likely to bypass your issue instead of helping. Post titles such as &amp;quot;Help Me&amp;quot;, &amp;quot;I Have A Problem&amp;quot;, &amp;quot;Question&amp;quot;, &amp;quot;Help me fix my code&amp;quot;, &amp;quot;This code doesn&#039;t work&amp;quot; or similarly worded titles will not readily draw forum users to your post. Experienced users (which are your best hope of resolving the issue) will often skip your post altogether in cases like this. An example of a post title descriptive enough to attract users to assist you is &amp;quot;Problem with WinWaitClose&amp;quot; or &amp;quot;Loop never ends&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Example for reproduction ===&lt;br /&gt;
Did you post example code? If you have not posted an example of the code you are having an issue with, then you will not recieve support. When posting a non-working script, please do so in the smallest amount of stand-alone code possible. If the code you post cannot run by itself on another person&#039;s computer, they will not be able to recreate the issue.&lt;br /&gt;
&lt;br /&gt;
=== Speak English and speak it right ===&lt;br /&gt;
Did you use proper English? Here are guidelines for posting properly in the english language:&lt;br /&gt;
* Use proper case.  THIS IS CONSIDERED YELLING. If you post in ALL UPPERCASE or all lowercase then you will look like a doofus.&lt;br /&gt;
* Use proper punctuation. Complete sentences need only one trailing punctuation mark -- not three!!! Writing a sentance without simple punctuation such as commas or other punctuation is considered lazy, which is considered a good judge of the poster&#039;s coding style. If you cannot summon the strength to write a sentence with correct punctuation, you will most likely miss simple coding mistakes such as unterminated quotes.&lt;br /&gt;
&lt;br /&gt;
=== Breaking forum rules, law, modesty, or common Sense ===&lt;br /&gt;
Make sure you are not giving the impression of breaking forum rules, http://www.autoitscript.com/forum/forum-2/announcement-15-forum-rules-7-nov-2012/. Make sure you are not doing anything that can be perceived as breaking the law.&lt;br /&gt;
&lt;br /&gt;
==Why does the Ctrl key get stuck down after I run my script?==&lt;br /&gt;
&lt;br /&gt;
=== Keys virtually stuck ===&lt;br /&gt;
It could equally be the Shift Or the Alt key.&lt;br /&gt;
&lt;br /&gt;
If you use Send In a script And you have a problem With keys being stuck down Then Send is the most likely culprit. A similar problem can occur With BlockInput. The solution is generally quite simple. If there is a key like Shift Or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes Then the key will get &#039;stuck&#039; down. As an example of a solution, you could replace the Send function in your script with the _SendEx function below.&lt;br /&gt;
&lt;br /&gt;
The _SendEx function waits for the Shift, Alt And Ctrl keys to be released or pops up a warning if the $warn parameter is not an empty string. Therefore it is not intended to be used when one of these modifier keys has been set to be down using any combination of {ALTDOWN}, {SHIFTDOWN} and {ALTDOWN}.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt; Misc.au3 &amp;gt;&lt;br /&gt;
;Send the string $ss after the Shift Alt and Ctrl keys are released. Optionally give a warning after 1 sec if any of those keys are still down.&lt;br /&gt;
;Requires misc.au3 to be included in the script for the _IsPressed function.&lt;br /&gt;
Func _SendEx($ss, $warn = &amp;quot;&amp;quot;)&lt;br /&gt;
	Local $iT = TimerInit()&lt;br /&gt;
&lt;br /&gt;
	While _IsPressed(&amp;quot;10&amp;quot;) Or _IsPressed(&amp;quot;11&amp;quot;) Or _IsPressed(&amp;quot;12&amp;quot;)&lt;br /&gt;
		If $warn &amp;lt;&amp;gt; &amp;quot;&amp;quot; And TimerDiff($iT) &amp;gt; 1000 Then&lt;br /&gt;
			MsgBox(262144, &amp;quot;Warning&amp;quot;, $warn)&lt;br /&gt;
		EndIf&lt;br /&gt;
		Sleep(50)&lt;br /&gt;
	WEnd&lt;br /&gt;
	Send($ss)&lt;br /&gt;
EndFunc;==&amp;gt;_SendEx&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== General unstuck method ===&lt;br /&gt;
Shilbiz also discovered that the following can &#039;clear&#039; locked down keys.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt; ControlSend(&amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;text&amp;quot;, 0)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I use Pixel functions?==&lt;br /&gt;
&lt;br /&gt;
=== Using a color change as an event ===&lt;br /&gt;
The following is an example of using the pixel to check if the colour has changed in a specific region.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $PixelCheck, $NewCheck&lt;br /&gt;
$PixelCheck = PixelCheckSum(40, 50, 60, 70); Get the checksum for this area.&lt;br /&gt;
While 1; Keep going&lt;br /&gt;
	$NewCheck = PixelCheckSum(40, 50, 60, 70)&lt;br /&gt;
	If $PixelCheck &amp;lt;&amp;gt; $NewCheck Then&lt;br /&gt;
		; The old pixel checksum and the new one are different.&lt;br /&gt;
		$PixelCheck = $NewCheck; Update the $PixelCheck to the new value&lt;br /&gt;
		; Let us now it has changed.  Change this to what you want to happen when the colour in the region changes.&lt;br /&gt;
		Msgbox(48,&amp;quot;PixelChecksum&amp;quot;,&amp;quot;Pixel region has changed !&amp;quot;)&lt;br /&gt;
	EndIf&lt;br /&gt;
	Sleep(50); Just to give the CPU a bit of a break.&lt;br /&gt;
Wend&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Searching for a specific pixel color ===&lt;br /&gt;
This is an example of searching for a specific pixel (red), both pure red (0xFF0000) and red in a few different shades.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;; Find a pure red pixel in the range 0,0-20,300&lt;br /&gt;
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )&lt;br /&gt;
If Not @error Then&lt;br /&gt;
	MsgBox(0, &amp;quot;X and Y are:&amp;quot;, $coord[0] &amp;amp; &amp;quot;,&amp;quot; &amp;amp; $coord[1])&lt;br /&gt;
EndIf&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Find a pure red pixel or a red pixel within 10 shades variations of pure red&lt;br /&gt;
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000, 10 )&lt;br /&gt;
If Not @error Then&lt;br /&gt;
	MsgBox(0, &amp;quot;X and Y are:&amp;quot;, $coord[0] &amp;amp; &amp;quot;,&amp;quot; &amp;amp; $coord[1])&lt;br /&gt;
EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Why doesn&#039;t my script work on a locked workstation?==&lt;br /&gt;
On a locked station any window will never be active (active is only dialog with text &amp;quot;Press Ctrl+Alt+Del&amp;quot;).  In Windows locked state applications run hidden (behind that visible dialog) and do not have focus and active status.  So generally don&#039;t use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.  Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.  This way you may have your script resistive against another active windows.  It&#039;s possible to run such a script from scheduler on locked Windows stations.&lt;br /&gt;
&lt;br /&gt;
==Where can I learn AutoIt? Are there any tutorials?==&lt;br /&gt;
To learn AutoIt you have two main options available to you:&lt;br /&gt;
&lt;br /&gt;
AutoIt 1-2-3, an interactive classroom by Valuater. You may find it here:&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=21048 http://www.autoitscript.com/forum/index.php?showtopic=21048]&lt;br /&gt;
&lt;br /&gt;
There is also updated LxP&#039;s AutoIt tutorial by BrettF. You can find it here:&lt;br /&gt;
[http://www.autoitscript.com/forum/index.php?showtopic=84960 http://www.autoitscript.com/forum/index.php?showtopic=84960]&lt;br /&gt;
&lt;br /&gt;
There is also a book; AutoIt v3: Your Quick Guide by Andy Flessner.&lt;br /&gt;
You can buy the book from here:&lt;br /&gt;
[http://oreilly.com/catalog/9780596515126/ http://oreilly.com/catalog/9780596515126/]&lt;br /&gt;
&lt;br /&gt;
On YouTube there are many videos available:&lt;br /&gt;
[http://www.youtube.com/results?search_query=autoit+tutorial&amp;amp;search_type=&amp;amp;aq=0&amp;amp;oq=AutoIt http://www.youtube.com/results?search_query=autoit+tutorial&amp;amp;search_type=&amp;amp;aq=0&amp;amp;oq=AutoIt]&lt;br /&gt;
&lt;br /&gt;
==Why does my script no longer decompile?==&lt;br /&gt;
Decompilation is no longer supported, and is only available for the older versions of AutoIt (Version 3.2.5.1 and earlier compiled scripts).&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;do not&#039;&#039;&#039; post on this topic, but search the forums for more information.  Posting topics like this will usually get the topic locked.&lt;br /&gt;
&lt;br /&gt;
Also posting the source (if a hacked decompiler was used) of other compiled scripts, or otherwise mentioning these hacked decompilers will probably get you banned.  It is also in violation of the AutoIt EULA (End-User-License-Agreement).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;You may not reverse engineer or disassemble the SOFTWARE PRODUCT or compiled scripts that were created with the SOFTWARE PRODUCT.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please see the [[Decompiling FAQ]] for more information.&lt;br /&gt;
&lt;br /&gt;
==How can I get a window handle when all I have is a PID?==&lt;br /&gt;
Refer to the following example showing converting and use when manipulating the window. The function is based on work by Smoke_N/Hubertus and Helge.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;;Run process&lt;br /&gt;
$iPID = Run(&amp;quot;Notepad.exe&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
;Allow window to initialize...&lt;br /&gt;
Sleep (500)&lt;br /&gt;
&lt;br /&gt;
;Get HWND.&lt;br /&gt;
$hWnd = _GetHwndFromPID($iPID)&lt;br /&gt;
&lt;br /&gt;
;Maximize&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_MAXIMIZE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Minimize&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_MINIMIZE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Restore window&lt;br /&gt;
WinSetState($hWnd, &amp;quot;&amp;quot;, @SW_RESTORE)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Move top left corner of screen, and resize to 800x600&lt;br /&gt;
WinMove($hWnd, &amp;quot;&amp;quot;, 0, 0, 800, 600)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Calculate Center of screen.&lt;br /&gt;
$x = (@DesktopWidth / 2) - 400; Desktop width divided by 2, then minus half the width of the window&lt;br /&gt;
$y = (@DesktopHeight / 2) - 300; Desktop height divided by 2, then minus half the height of the window&lt;br /&gt;
&lt;br /&gt;
;Move to center of screen&lt;br /&gt;
WinMove($hWnd, &amp;quot;&amp;quot;, $x, $y)&lt;br /&gt;
&lt;br /&gt;
;Wait 2 seconds&lt;br /&gt;
Sleep(2000)&lt;br /&gt;
&lt;br /&gt;
;Close notepad&lt;br /&gt;
WinClose($hWnd)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Function for getting HWND from PID&lt;br /&gt;
Func _GetHwndFromPID($PID)&lt;br /&gt;
	$hWnd = 0&lt;br /&gt;
	$winlist = WinList()&lt;br /&gt;
	Do&lt;br /&gt;
		For $i = 1 To $winlist[0][0]&lt;br /&gt;
			If $winlist[$i][0] &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;
				$iPID2 = WinGetProcess($winlist[$i][1])&lt;br /&gt;
				If $iPID2 = $PID Then&lt;br /&gt;
					$hWnd = $winlist[$i][1]&lt;br /&gt;
					ExitLoop&lt;br /&gt;
				EndIf&lt;br /&gt;
			EndIf&lt;br /&gt;
		Next&lt;br /&gt;
	Until $hWnd &amp;lt;&amp;gt; 0&lt;br /&gt;
	Return $hWnd&lt;br /&gt;
EndFunc;==&amp;gt;_GetHwndFromPID&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I use single or double quotes in strings?==&lt;br /&gt;
It is a fairly simple concept once you get the basics down.  Basically there are a few different ways to go about mixing quotes in strings.&lt;br /&gt;
&lt;br /&gt;
A string in AutoIt can be encased in either single(&#039;) or double (&amp;quot;) quotes.  So if you want to add only one type of quote into your string, your first port of call is to use the other type of quote to encase the string.  Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$var = &amp;quot;I am a &#039;quote&#039; inside the string&amp;quot;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&lt;br /&gt;
$var = &#039;I wish I could be a &amp;quot;quote&amp;quot; inside the string!&#039;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have to have both types of quotes in the string, the easiest way is to escape the quote ending the string as so to speak.  To do this, use two quotes instead of one.  Like so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;$var = &#039;I am a single &#039;&#039;quote&#039;&#039; inside the string made using &amp;quot;single quote!&amp;quot;&#039;&lt;br /&gt;
MsgBox (0, &amp;quot;Test 1&amp;quot;, $var)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==When should I bump my threads?==&lt;br /&gt;
As a courtesy to other users you should only bump your post once in a 24 hour period.  Doing this allows all users the chance to get helped equally.  Also refer to [http://www.autoitscript.com/forum/index.php?showtopic=95704&amp;amp;view=findpost&amp;amp;p=688050 Why isn&#039;t my thread getting any replies?], as this will help you get replies.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How can I protect my code from decompilation?==&lt;br /&gt;
The fact of the matter is &#039;&#039;&#039;you can&#039;t fully protect your code&#039;&#039;&#039;.  AutoIt is an  interpreted language, so all scripts are interpreted, and that script has to get stored somewhere.  There is still hope though.  You can take certain measures to prevent decompiled code from being usable to the person that decompiled.  The first step is to obfuscate your code.  This causes the code to become unreadable.  Basically variables and functions are renamed, making it very hard to make head or tail of what is what.&lt;br /&gt;
&lt;br /&gt;
Please see the [[Decompiling FAQ]] for more information.&lt;br /&gt;
&lt;br /&gt;
==How can I decompile my AutoIt EXEs?==&lt;br /&gt;
You cannot decompile your AutoIt compiled scripts unless it was compiled with AutoIt 3.2.5.1 or earlier.&lt;br /&gt;
&lt;br /&gt;
If you wish to simulate decompilation for your script, you can do this using the following simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;;Original Author SmokeN&lt;br /&gt;
If $CMDLINE[0] Then&lt;br /&gt;
	If $CMDLINE[1] == &amp;quot;/SOURCE&amp;quot; AND $CMDLINE[2] == &amp;quot;MYPASSWORD&amp;quot; Then&lt;br /&gt;
		FileInstall(&amp;quot;ThisSCript.au3&amp;quot;, @ScriptDir &amp;amp; &amp;quot;\DecompiledScript.au3&amp;quot;)&lt;br /&gt;
	EndIf&lt;br /&gt;
EndIf&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then if you run the exe with the following command line parameters your source will be installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;myscript.exe /SOURCE MYPASSWORD&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== What is proper forum etiquette?  What rules are there for the forum?==&lt;br /&gt;
Proper forum etiquette will ensure you will stay a member of these forums.  So try to follow these rules.  Also see this [http://www.autoitscript.com/forum/index.php?showtopic=95704&amp;amp;st=15&amp;amp;p=688050&amp;amp;#entry688050 FAQ post], as you should follow what is outlined there as well.&lt;br /&gt;
&lt;br /&gt;
* Use proper English.  MSN speak and the like makes it very hard to understand what you want.  Keep posts in proper case because UPPERCASE is considered yelling and lowercase makes you look stupid.  Don&#039;t use more punctuation marks than necessary. For example ?!!!? and ????? is completely unnecessary.&lt;br /&gt;
* Before posting help with a script, make sure you follow these steps:&lt;br /&gt;
*# Search for your issue.&lt;br /&gt;
*#* There are many thousands of posts on this forum, and chances are your question has been asked before.  Make sure to use a variety of terms to maximize your results.&lt;br /&gt;
*# Read the helpfile&lt;br /&gt;
*#* Most if not all things in the help file will have an example (native functions) or two.  Give them a go to try see how the functions work.  Most of the time it helps!&lt;br /&gt;
*# Give it a go&lt;br /&gt;
*#* Seriously, if you can&#039;t be bothered to give it a go, then why should we be bothered to help you?  If you feel you can&#039;t do it and you don&#039;t try then how will you ever know?  We always prefer that you give it a go because you can learn from your mistakes and hopefully understand it better.&lt;br /&gt;
*# Post your problem&lt;br /&gt;
*#* Make sure you post in the correct forum.&lt;br /&gt;
*#** AutoIt Specific&lt;br /&gt;
*#*** General Help and Support (Most support questions)&lt;br /&gt;
*#*** GUI Support (Support for the Graphical User Interface)&lt;br /&gt;
*#** Non-AutoIT&lt;br /&gt;
*#*** Chat&lt;br /&gt;
*#*** Developer Chat (Usually for C++ questions.)&lt;br /&gt;
*#* Include a detailed description in the content of the post, and a detailed title&lt;br /&gt;
*#** Titles such as &#039;Help&#039; and &#039;What&#039;s wrong?&#039; are not acceptable.  To get the most help with your problem, be as descriptive as you can in the title, but keep in mind your title cannot be too long.&lt;br /&gt;
*#** Make sure you also include a descriptive question.  Just saying &#039;what is wrong with the following&#039; is also not acceptable, as we will have no idea what the problem is.  Describe what you think is wrong and what is not working.  It makes our job easier.&lt;br /&gt;
*#* Always include your code&lt;br /&gt;
*#** It shows us that you have tried and gives us a head start with something to play with.&lt;br /&gt;
* Usually asking for a script is not taken too well, within reason.  Keep in mind that this is a support forum, so please acknowledge that.   Most of us would rather that you learn rather than just having a script written for you.  If you do need something written for you, maybe try  [http://www.rentacoder.com/ RentACoder], as they are more suited to requests.&lt;br /&gt;
* Don&#039;t PM other members asking for them to look at threads of to help you unless they request it.  It is actually quite rude and annoying to receive PMs of that nature.&lt;br /&gt;
* Lurk a little before you dive right in. Read a number of posts, or check out the group&#039;s archives. Get a feel for the tone of the forum so you can participate accordingly.&lt;br /&gt;
* Say online exactly what you would say in person. In other words, if you wouldn&#039;t say it to the person&#039;s face in front of your Grandmother, you shouldn&#039;t type it here.&lt;br /&gt;
* Remember your face doesn&#039;t show. Words alone can convey sentiment, but without benefit of inflection or facial expression, they can be misconstrued. Use descriptive wording, emoticons or .gifs to ensure your meaning is clear. By the same token, don&#039;t jump to conclusions about another person&#039;s intent in posting an unclear comment. When in doubt, ask for clarification.&lt;br /&gt;
* Be respectful. Internet etiquette is similar to standard etiquette in this area. Appreciate that your opinion is one of many. You can disagree with another person without being disrespectful or rude to other people.&lt;br /&gt;
* Ignore Trolls. If you engage in conversation with one, you&#039;ll raise your blood pressure and empower the troll. You can&#039;t win a flame war, and you can&#039;t sway a troll&#039;s opinion. Often, they don&#039;t even care about the subject.  They live for the conflict and nothing more. Trolls are common and not worthy of your time. Ignore their posts no matter how inflammatory and eventually they&#039;ll get bored and move on.&lt;br /&gt;
* When you have found an answer for your question:&lt;br /&gt;
*# Do not edit your post to be blank or to have worthless information.  People may be searching for the same issue you have, so be courteous to them by leaving your question there.&lt;br /&gt;
*# It is also optional to add the likes of [SOLVED] into the title, and redirecting people to the answer that helped you.  It can make the lives of people searching easier.&lt;br /&gt;
* Finally follow the rules:&lt;br /&gt;
** [http://www.autoitscript.com/forum/forum-6/announcement-13-forum-rules/ Forum rules]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=54168 Rules for the Chat forum]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=65889 Rules for asking for source code]&lt;br /&gt;
** [http://www.autoitscript.com/forum/index.php?showtopic=37739 General policies and forum settings]&lt;br /&gt;
&lt;br /&gt;
Some general points taken from [http://www.ehow.com/how_2106033_use-proper-forum-etiquette.html here].&lt;br /&gt;
&lt;br /&gt;
==Are there forums available in my local language?==&lt;br /&gt;
Yes there are some available.  Some forum members here participate in multiple forums.&lt;br /&gt;
* [http://www.autoit.de/ German Forums]&lt;br /&gt;
* [http://www.autoit.fr/  French Forums]&lt;br /&gt;
* [http://www.autoit.es/ Spanish Forums]&lt;br /&gt;
* [http://autoit-script.ru/ Russian Forums]&lt;br /&gt;
&lt;br /&gt;
Please note that these are independent, community-run message boards and not just a translation of this board.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=10906</id>
		<title>User Defined Functions</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User_Defined_Functions&amp;diff=10906"/>
		<updated>2012-11-09T01:13:51Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Internet protocol suite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WIP}}&lt;br /&gt;
&lt;br /&gt;
This page is a listing of libraries of user defined functions. These libraries have been written to allow easy integration into your own script and are a very valuable resource for any programmer.&lt;br /&gt;
&lt;br /&gt;
== Automation ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=87956 Java UDF] - Creates an access bridge between your application and a Java application. Allowing you to automate some Java applications.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=86574 SAP] - SAP business management automation.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=42776 PDFCreator] - Automation of PDFCreator allows you to create and manipulate PDF files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=91018 WiFi] - Low level control over your wireless LAN &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106163 Active Directory] - Extensive library to control and manipulate the Windows active directory. Link to the [[Active_Directory_UDF_-_General|documentation]] pages. &lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=28436 Windows Events] - Create your own Windows events.&lt;br /&gt;
&lt;br /&gt;
===Browsers===&lt;br /&gt;
* Internet Explorer - Everything about Internet explorer can be automated with the IE library supplied with a standard AutoIt install.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95595 FireFox] - A little less support for automation than IE, but still very good.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=61090 Opera] - The same as above for Opera. Automate the most common tasks in Opera with the Opera UDF.&lt;br /&gt;
&lt;br /&gt;
===Microsoft Office Automation===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32144 Microsoft Office Access] - Automation of Access.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=34302 Microsoft Office Excel] - Large automation library for Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/135312-excelchart-udf Microsoft Office Excel] - Creating charts using Excel.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126305-outlookex-udf/ Microsoft Office Outlook] - Extended Outlook UDF. Link to the [[OutlookEX_UDF_-_General|documentation]] pages.&lt;br /&gt;
* Microsoft Office Word UDF - A way to automate Office Word is included with AutoIt.&lt;br /&gt;
&lt;br /&gt;
== Hardware ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=45842 Serial port (COM port)] - Requires my comMG.dll (included)&lt;br /&gt;
&lt;br /&gt;
== Information gathering ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=29404 Computer information] - A general purpose library to get various details about a Windows machine.&lt;br /&gt;
&lt;br /&gt;
== Databases and web connections ==&lt;br /&gt;
* FTP - A FTP library is now included with the AutoIt libraries.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=17099 SQLite] - &amp;quot;SQLite is a library that implements a self-contained, embeddable, zero-configuration SQL database engine&amp;quot;&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=19848 XML DOM Wrapper] - Supports CRUD operations on XML. Including XSL and XPath.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20814 MySQL] - MySQL relational database management system UDF.&lt;br /&gt;
&lt;br /&gt;
== Internet protocol suite ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/84133-winhttp-functions/ HTTP] - For creating GET and POST requests and submitting them with conforming standards.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=22838 POP3] - POP3 library for retrieving email messages. Not compatible with Gmail because it uses SSL.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=64051 POP3 SSL] - A POP3 library that&#039;s compatible with Gmail. It uses an external executable that must be supplied with your script.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=43515 IRC] - A lightweight library for communicating with IRC servers.&lt;br /&gt;
&lt;br /&gt;
== Data compression ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=116565 zip] - Create ZIP files and unpack ZIP files.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=85094 7z, zip, gzip, bzip2, tar] - More extensive library than the one above. Uses a external DLL that must be provided with the script.&lt;br /&gt;
&lt;br /&gt;
== Encryption and hash ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=76976 MD5,SHA1,CRC32,RC4,BASE64,XXTEA] - Several encryption and hash functions.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=78745 AES Rijndael] - Very fast AES UDF. Support ECB/CBC/CFB/OFB block cipher mode.&lt;br /&gt;
&lt;br /&gt;
== Media ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=94834 Simple DirectMedia Layer UDF] - Adds support for joysticks, CDs, 2D graphics, timers. See [http://www.libsdl.org/ SDL website] for more information.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=95357 FreeImage library] - Various operations on images, such as rotate, resize, flip.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=51054 Printer controller] - Print text in any font, size and colour at any position on the page, draw lines, curves, elipses, pies in any colour, and print images.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=42776 PDF creator]&lt;br /&gt;
&lt;br /&gt;
===Sound===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83481 BASS Function Library] - Sound and Music via wrappers for Bass, BassEnc, Bass FX, BassSFX, BassAsio and BassCd DLLs&lt;br /&gt;
&lt;br /&gt;
===3D graphics===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=70506 IrrLicht] - A 3D graphics engine suitable for creating games.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=113881 au3Irrlicht2] - Another UDF bringing Irrlicht and au3 together. Historically some kind of a follower of the UDF above, technically with a complete different approach.&lt;br /&gt;
&lt;br /&gt;
== GUI Additions ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=32494 XSkin] - A large library that allows skinning of your GUI and to apply custom skins.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=20967 Modern tray menu] - Allows the creation of modern, fancy GUI and tray menus with icons.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=71811 SetOnEvent] - Provides an easy way for an event to call functions with parameters.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/119505-guiframe-udf-melba23-version/ GUIFrame] - Divide a GUI into adjustable frames.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/113723-scrollbars-made-easy/ Easy Scrollbars] - Easily create scrollable sections in your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105582 GUICtrlOnChangeRegister] - Call a function when an edits content is changed.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96258-contexthelp-au3/ ContextHelp.au3] - Management of context help ([http://www.autoitscript.com/forum/topic/72152-contexthelp/ original])&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/117909-guiextender-new-version-171110/ GUIExtender] - Expand and contract sections of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/109096-extended-message-box-new-version-3-dec-10/ ExtMsgBox] - A very customisable replacement for MsgBox&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/108445-how-to-make-toast/ Toast] - Small message GUIs which pop out of the Systray&lt;br /&gt;
&lt;br /&gt;
=== Controls ===&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=79412 Graph control UDF] - Easily create and show bar chart and line charts.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=105682 GUICtrlCreateFinder] - Allows you to create a window finder control like the one seen in AutoIt Window Info.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=111438 GUIPager] - Create and control native pager controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=90598 Hotkey input control] - Hotkeys Input Control UDF Library (Non-native)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=107965 GUIHotkey] - UDF for using native hotkey controls.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/103904-info-bar-like-tickertape/page__view__findpost__p__735769 Marquees] - Make tickertape info bars&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/96464-colorpicker-udf/ Colorpicker] - Create a button for the user to select a color.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/126958-guisyslink-udf/ Syslink] - Provides a convenient way to embed hypertext links in a window&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/74649-progressbar-with-gdiplus/ Progressbar with GDIplus] - You even can use full textured images&lt;br /&gt;
&lt;br /&gt;
== Maths ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83091 Primes UDF] - Many functions dealing with prime number generation and calculations.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=83529 Big number UDF] - Make calculations with extremely large numbers that AutoIt normally is not able to support.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=81189 Number base conversion] - From, to and between positive bases less than 63 (decimals supported)&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=106551 Decimal To fraction] - Converts any decimal number to a fraction. Example: 1.2 to 6/5&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=82722 Trigonometry math functions] - _ATan2(), _Cosh(), _Frexp(), _Hypot(), _Ldexp(), _Logb(), _Sinh(), _Tanh()&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=108803 Polynomials] - Functions for using polynomials.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=117156 NumToWord] - Convert numerals to a human readable string.&lt;br /&gt;
* [http://www.autoitscript.com/forum/index.php?showtopic=98160 Root function] - Working out real roots of numbers.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/102686-advanced-rounding/ Advanced rounding] - Support for different measures of accuracy and 8 ways to resolve tie breaks.&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/90492-hotkey-au3/ Hotkey.au3] - Management of Hotkeys UDF, with several advantages over HotkeySet().&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/97826-animateau3-updated/ Animated tray icons] - Make animated tray icons easily.&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/101733-prevent-dotted-focus-lines-on-controls/ NoFocusLines] - Remove the dotted focus lines from buttons, sliders, radios and checkboxes which spoil the look of your GUI&lt;br /&gt;
* [http://www.autoitscript.com/forum/topic/114034-stringsize-m23/ StringSize] - Automatically size controls to fit the text you want to put in them&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10904</id>
		<title>SciTE4AutoIt3</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=SciTE4AutoIt3&amp;diff=10904"/>
		<updated>2012-11-09T00:57:17Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;SciTE4AutoIt3 is a specialist editor package based around the excellent [http://www.scintilla.org/SciTE.html SciTE] editor.  The editor has been set up to compile AutoIt scripts.  SciTE has been extended with a multitude of lua scripts.  SciTE4AutoIt3 may be downloaded here: [http://www.autoitscript.com/site/autoit-script-editor/ SciTE4AutoIt3]&lt;br /&gt;
&lt;br /&gt;
==Features==&lt;br /&gt;
SciTE4AutoIt3 comes with a configuration program named SciTEConfig.  With SciTEConfig a user may change the color scheme of SciTE.  One may also change the default Au3 script file double-click action from edit to run.  Also available are calltips, abbreviations, and quick access to the helpfile.  To access the helpfile the user may press Alt + F1. To quickly access help information on a specific function/statement, simply click/highlight the function/statement in question and press the F1 key to bring up the help file on the relevant page.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10902</id>
		<title>User:FlutterShy</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=User:FlutterShy&amp;diff=10902"/>
		<updated>2012-11-09T00:48:02Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: Created page with &amp;quot;I try to fix grammatical errors, syntax errors as I see and remember them.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I try to fix grammatical errors, syntax errors as I see and remember them.&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10901</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10901"/>
		<updated>2012-11-09T00:46:20Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: Undo revision 10900 by FlutterShy (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $i&lt;br /&gt;
 For $i = 1 to 10 Step 2&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
 Do&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 	If $c = 2 Then ExitLoop&lt;br /&gt;
 Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MySimplestUDF()&lt;br /&gt;
    ;This does nothing at the moment&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10900</id>
		<title>Tutorial Core Language</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Tutorial_Core_Language&amp;diff=10900"/>
		<updated>2012-11-09T00:43:57Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Mathematical Comparison */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial describing the core elements of the AutoIt language.&lt;br /&gt;
&lt;br /&gt;
=Comments=&lt;br /&gt;
Two types of comments tend to exist in every language. Comments are simply lines/blocks of code that are meant as guidelines or notes to help understand what the code is doing.&lt;br /&gt;
&lt;br /&gt;
Inline/Single-line comments may be added using a preceeding semicolon.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
; This is a single-line comment&lt;br /&gt;
msgbox(1,&amp;quot;Title&amp;quot;,&amp;quot;Text&amp;quot;) ; This is an inline comment&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Where as multiline comments are a little less intuitive but just as effective...&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#comments-start&lt;br /&gt;
  All code within this block is commented and will not be interpretted at compile/run time.&lt;br /&gt;
#comments-end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There&#039;s also a shorthand method to this.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
#cs&lt;br /&gt;
 All code within this block is commented as well.&lt;br /&gt;
#ce&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Variables=&lt;br /&gt;
==Declarations==&lt;br /&gt;
A variable is a placeholder in memory where we can store some kind of data. In AutoIt the data is a string, number or reference to an array.&lt;br /&gt;
AutoIt has three keywords to declare a variable. Namely Global, Local and Dim. When we declare a variable we set aside some memory for the variable. &lt;br /&gt;
All variable names in AutoIt starts with a $ sign. So they are easy spotted in the code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Global $gVar&lt;br /&gt;
 Local $Var&lt;br /&gt;
 Dim $i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Arrays are simply collections of variables stored under a common name using addresses as a means of defining their position within memory. Similar to defining a variable, the only difference in defining an array is expressing the number of elements to be attributed to that collection.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Global $aarr[4] ; 4 elements allocated.&lt;br /&gt;
Local  $barr[1] ; 1 element allocated.&lt;br /&gt;
Dim    $carr[3] ; 3 elements allocated. ; Try to avoid Dim, use Global and Local.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more on arrays visit the [[Arrays|Arrays Tutorial]] page.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
Generally speaking, scope pertains to the length of time for which a variable is visible or more precisely how long a variable is stored in memory before it returns to a free state. As such, the allocation(declaration) and deallocation(trash collection) of a variable is usually left up to the compiler/interpreter and occasionally is given to the user to play with. As a rule of thumb, all information stored in memory for a program is deallocated upon completion of the program. &lt;br /&gt;
&lt;br /&gt;
Why is this important? Scope allows a developer to track and reuse variable names for multiple occurances. Imagine having to create a unique name for every single variable stored in memory at that point. You would have to compensate for all the variable names used in the operating system, other programs running parallel to yours, and every name in your own script. It wouldn&#039;t be long before randomly generated 256 character names would be more efficient than a list of used names.&lt;br /&gt;
&lt;br /&gt;
With this in mind the three methods of declaring a variable explained above have different scopes in mind:&lt;br /&gt;
*Global variables are given scope over the entire program&#039;s run.&lt;br /&gt;
*Local variables have a scope that is immediately related to the block of code they&#039;re currently a member of.&lt;br /&gt;
*Dim variables are hybrid-like depending upon whether or not the name is already defined in a global variable status:&lt;br /&gt;
**Global variable exists of the same name&lt;br /&gt;
***Overwrites the Global variable&lt;br /&gt;
**Global variable does not exist&lt;br /&gt;
***Creates a Local variable for that block&lt;br /&gt;
&lt;br /&gt;
=Assignment=&lt;br /&gt;
Assigning a value to a variable is the only way to get things going. Fortunately, AutoIt uses loose typing...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = &amp;quot;Hi there!&amp;quot;  ; $x is a string&lt;br /&gt;
$x = 7                  ; $x is an integer&lt;br /&gt;
$x = .15                ; $x is a float&lt;br /&gt;
$x = 123456789          ; $x is a double&lt;br /&gt;
$x = &amp;quot;Hello again!&amp;quot;     ; $x is back to a string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Loose typing simply means a variable is malleable and its format can be changed to your liking, this also means that you have to watch your scope and what&#039;s going in and out of that variable.&lt;br /&gt;
&lt;br /&gt;
Arrays are handled a bit differently. They may contain several different types and those types are loosely typed but the array must have a predetermined size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $y[3]&lt;br /&gt;
$y[0] = 1        ; first address is an integer&lt;br /&gt;
$y[1] = &amp;quot;two&amp;quot;    ; second address is a string&lt;br /&gt;
$y[2] = 3.33333  ; third address is a float&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Equivalently&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $z[3] = [1,&amp;quot;two&amp;quot;,3.3333]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Again, for more on arrays see the [[Arrays|Arrays Tutorial]].&lt;br /&gt;
&lt;br /&gt;
You may also declare and assign several variables at the same time.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $x = 1, $y = &amp;quot;&amp;quot;, $z[3] = [1,2,3]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Operators=&lt;br /&gt;
===Assignment===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Assignment operator. e.g. $var = 5&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;amp;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Concatenation assignment. e.g. $var &amp;amp;= &amp;quot;Hello&amp;quot; equivalent to $var = $var &amp;amp; &amp;quot;Hello&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
===Mathematical Operation===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; + &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition operator. e.g. 10 + 20&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; - &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction operator. e.g. 20 - 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; * &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplication operator. e.g. 20 * 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; / &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Division operator. e.g. 20 / 10&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; ^ &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Powers operator. e.g. 2 ^ 4&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; += &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Addition assignment. e.g. $var += 1 is equivalent to $var = $var + 1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; -= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Subtraction assignment. e.g. $var -= 1 is equivalent to $var = $var -1&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; *= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Multiplicative assignment. e.g. $var *= 2 is equivalent to $var = $var * 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; /= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Divisive assignment. e.g. $var /= 2 is equivalent to $var = $var / 2&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Mathematical Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; = &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator for numerical values. e.g. If $var = 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator for string values. e.g. If $string == &amp;quot;string&amp;quot; Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equal operator. e.g. If $var &amp;lt;&amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than operator. e.g. If $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;gt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Greater-than-or-Equal-to operator. e.g. If $var &amp;gt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than operator. e.g. If $var &amp;lt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;= &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Less-than-or-Equal-to operator. e.g. If $var &amp;lt;= 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===String Comparison===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;  =  &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var = &amp;quot;Hi&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; == &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Equivalence operator. e.g. If $var == &amp;quot;Bye&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; &amp;lt;&amp;gt; &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent operator. e.g. If $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case insensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;Not &amp;lt;&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Not equivalent combinative operator. e.g. If Not $var &amp;lt;&amp;gt; &amp;quot;blah&amp;quot; Then ... ; case sensitive.&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Logical===&lt;br /&gt;
&amp;lt;table border=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; And &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical And operator. e.g. If $var &amp;gt; 5 And $var &amp;lt; 3 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Or &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Binary logical Or operator. e.g. If $var &amp;lt;&amp;gt; 5 Or $var &amp;lt;&amp;gt; 6 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt; Not &amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;Unary inversion operator. e.g. If Not $var &amp;gt; 5 Then ...&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Precedence===&lt;br /&gt;
All languages have a list of precedences that define when an operator is to be evaluated. Operators with equal precedence are evaluated from &#039;&#039;left&#039;&#039; to &#039;&#039;right&#039;&#039;.&lt;br /&gt;
 From highest to lowest:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
  &#039;&#039;&#039;Not&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; ^ &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;* /&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;+ -&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039; &amp;amp; &#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;= = &amp;lt;&amp;gt; ==&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;And Or&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
It should be noted that the use of And/Or operators evaluate from left to right such that&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt; 5 And $x &amp;gt; 3 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
checks the &#039;&#039;$x &amp;lt; 5&#039;&#039; first and if it returns false will not evaluate &#039;&#039;$x &amp;gt; 3&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Similarly for Or&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 If $x &amp;lt;&amp;gt; 5 Or $x &amp;lt;&amp;gt; 6 Then &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
will evaluate &#039;&#039;$x &amp;lt;&amp;gt; 5&#039;&#039; and if it returns true will not evaluate &#039;&#039;$x &amp;lt;&amp;gt; 6&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
All tables and information adapted from the [http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm AutoIt intro].&lt;br /&gt;
&lt;br /&gt;
=Branching=&lt;br /&gt;
Branching is to let the computer compare something and based on the result let it execute a block of code.&lt;br /&gt;
Autoit has three keywords for identifying branching. They are If, Select and Switch. In addition there are several sub keywords to identify the comparing code and assosiated block of code.&lt;br /&gt;
==If-ElseIf-Else==&lt;br /&gt;
When a test returns a true statement then execute code block down to the assosiated ElseIf, Else or EndIf keyword. If Else or Else if was encountered then jump to the EndIf Line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $x = 1&lt;br /&gt;
&lt;br /&gt;
If $x = 1 Then&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
 &lt;br /&gt;
If $x &amp;lt; 2 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
ElseIf $x &amp;gt;= 3 Then &lt;br /&gt;
   ;Code block&lt;br /&gt;
Else&lt;br /&gt;
   ;Code block&lt;br /&gt;
EndIf&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
There also exists a shorthand method of the If statement:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
If true = 1 then MsgBox(1,&amp;quot;Is it true?&amp;quot;,&amp;quot;Yarp!&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Select==&lt;br /&gt;
&#039;&#039;Select&#039;&#039; is simply a (arguably) more readable version of an if-elseif-else statement.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Select &lt;br /&gt;
     Case $var = 1&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case $var = 2&lt;br /&gt;
         ;Code block&lt;br /&gt;
     Case Else&lt;br /&gt;
         ;Code block&lt;br /&gt;
 EndSelect&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Switch==&lt;br /&gt;
The Switch statement contains an interesting difference to most languages. In AutoIt&#039;s case, it is equivalent to the Select statement. Once a block of code is executed the Switch statement exits. Unlike most other languages, a &#039;&#039;break&#039;&#039; is not required at the end of each case to avoid trickle-down. This may be considered disadvantageous due to the lack of multi-conditional executions that the Switch statement is generally used for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Switch $var&lt;br /&gt;
    Case 1&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case 2&lt;br /&gt;
        ;Code block&lt;br /&gt;
    Case Else&lt;br /&gt;
        ;Code block&lt;br /&gt;
EndSwitch&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Loops=&lt;br /&gt;
A loop is used on a code block that we want to execute several times. In the codebloc we can have variables changing state for each iteration in the loop.&lt;br /&gt;
AutoIt has four types of loops. For...Next, For Each, While...Wend and Do ... Until&lt;br /&gt;
==For ... Next==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $i&lt;br /&gt;
 For $i = 1 to 10 Step 2&lt;br /&gt;
 Next&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==While ... WEnd==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 While $var &amp;lt; 100&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 WEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Do ... Until==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
A Do .. Until block will run at least once as the conditional check is done at the bottom of the block.&lt;br /&gt;
 Do&lt;br /&gt;
     Sleep(100)&lt;br /&gt;
     $var += 1&lt;br /&gt;
 Until $var = 100&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The code inside this Do ... Until block should only run once&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until True&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample will run until we forcefully us a ExitLoop command to escape the loop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 	If $c = 2 Then ExitLoop&lt;br /&gt;
 Until False&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This sample should run until $c equals 3&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Local $c&lt;br /&gt;
 Do&lt;br /&gt;
 	$c += 1&lt;br /&gt;
 	ConsoleWrite(&amp;quot;Run nr &amp;quot; &amp;amp; $c &amp;amp; @crlf)&lt;br /&gt;
 Until $c=3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For Each==&lt;br /&gt;
The For Each loop is often used for associative arrays however it is often handy when you don&#039;t know the size of your current array. In this case, the syntax and implementation is very similar to javascript which is slightly off the standard.&lt;br /&gt;
Assume we have an array $arr of undetermined size:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
Local $str = &amp;quot;&amp;quot;&lt;br /&gt;
for $stuff in $arr  ; for each item in our array&lt;br /&gt;
  $str &amp;amp;= $stuff    ; copy the item into our string&lt;br /&gt;
Next&lt;br /&gt;
MsgBox(1,&amp;quot;&amp;quot;,$str)   ; displays the contents of our string&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=User defined functions=&lt;br /&gt;
A function is a code block encapsulated by the keywords Func and EndFunc. Everytime you find yourselfe writing the same code again you can do three things. Write the code. Copy and paste the previously written code or wrap the code up in a function and call the function by name in your code.&lt;br /&gt;
==Defining==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MySimplestUDF()&lt;br /&gt;
    ;This does nothing at the moment&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Passing data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFAcceptingArguments($arg1, ByRef $arg2)&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Returning data==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
 Func MyUDFReturningResults($arg1, ByRef $arg2)&lt;br /&gt;
     Local $ret = 1&lt;br /&gt;
     ;Changing $arg2 is a way of returning data&lt;br /&gt;
     If IsNumeric($arg2) Then&lt;br /&gt;
         $arg2 = 2*$arg2&lt;br /&gt;
     Else&lt;br /&gt;
         $arg2 &amp;amp;= @CRLF &amp;amp; $arg2&lt;br /&gt;
     EndIf&lt;br /&gt;
     Return $ret&lt;br /&gt;
 EndFunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=File I/O=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==INI Files==&lt;br /&gt;
&lt;br /&gt;
Using IniWrite &amp;amp; IniRead to store values. Useful for scripts that run from independent source (network, USB Drive, etc..).&lt;br /&gt;
&lt;br /&gt;
Write:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     IniWrite(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Value&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Read:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
     $MyVar = IniRead(&amp;quot;FileName.INI&amp;quot;, &amp;quot;Section&amp;quot;, &amp;quot;Key&amp;quot;, &amp;quot;Default&amp;quot;); If INI data missing, $MyVar set to &amp;quot;Default&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sample &amp;quot;FileName.INI&amp;quot;:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
[Section]&lt;br /&gt;
Key=Value&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;***TODO: File I/O stuffs***&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10899</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10899"/>
		<updated>2012-11-09T00:28:47Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Comparing Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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;
&lt;br /&gt;
If $Array1 = $Array2 then&lt;br /&gt;
    ConsoleWrite(&amp;quot;+&amp;gt;Array is equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
Else&lt;br /&gt;
    ConsoleWrite(&amp;quot;!&amp;gt;Array is not equal!&amp;quot; &amp;amp; @LF)&lt;br /&gt;
EndIf&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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10898</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10898"/>
		<updated>2012-11-09T00:21:06Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Accessing Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10897</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10897"/>
		<updated>2012-11-09T00:13:07Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Arrays in arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10895</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10895"/>
		<updated>2012-11-09T00:10:55Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Arrays in arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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, again. You have to go through a variable to get access to the embedded array. &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 have to and are prepared to do rigorous testing to make sure your code will always work as you expect it to.&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10894</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10894"/>
		<updated>2012-11-08T23:58:39Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Multi dimensional arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10882</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10882"/>
		<updated>2012-11-08T22:57:54Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Changing array sizes with ReDim */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10881</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10881"/>
		<updated>2012-11-08T22:26:48Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Accessing Data in Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 Local $data=&amp;quot;Element 1|Element 2|Element 3&amp;quot; ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, &amp;quot;|&amp;quot;) If IsArray($arr) Then     $iMax = UBound($arr); get array size     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax &amp;amp; @LF)     For $i = 0 to $iMax - 1; subtract 1 form size to prevent out of bounds error         ConsoleWrite($arr[$i] &amp;amp; @LF)     Next 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 itterations. If the array are to small it should automatically be increased. Before we dump the array to output, we should adjust the 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;
 Local $i&lt;br /&gt;
 ;Get a random number between 0 and 20&lt;br /&gt;
 Local $rnd = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $rnd&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then &lt;br /&gt;
         ; Resize the array&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&lt;br /&gt;
     ; Remember to update the count or last item&lt;br /&gt;
     $arr[0] = $i&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 result&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;, $rnd:=&amp;quot; &amp;amp; $rnd &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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10880</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10880"/>
		<updated>2012-11-08T22:18:53Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Accessing Data in Arrays */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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)&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 StringSplit 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 a array containing data with a 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 itterations. If the array are to small it should automatically be increased. Before we dump the array to output, we should adjust the 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;
 Local $i&lt;br /&gt;
 ;Get a random number between 0 and 20&lt;br /&gt;
 Local $rnd = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $rnd&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then &lt;br /&gt;
         ; Resize the array&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&lt;br /&gt;
     ; Remember to update the count or last item&lt;br /&gt;
     $arr[0] = $i&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 result&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;, $rnd:=&amp;quot; &amp;amp; $rnd &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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10879</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10879"/>
		<updated>2012-11-08T21:58:18Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Assigning Data to Array Elements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 $i&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 3 - 1 construct used in the last sample looked strange.  It is not a good idea to hardcode size like that. So lets improve our sample a litle bit. &lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=3&lt;br /&gt;
 Local $i&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 is a bit cleaner. It is 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 you get the array from somewhere else.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax&lt;br /&gt;
 Local $i&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;
     Local $iMax = UBound($arr)&lt;br /&gt;
     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax)&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;
 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 StringSplit 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 a array containing data with a 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 $i&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 a 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 as 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 itterating with $arr[0] needs no other change than maintaining the correct &lt;br /&gt;
count in $arr[0]&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=10&lt;br /&gt;
 Local $i&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 itterations. If the array are to small it should automatically be increased. Before we dump the array to output, we should adjust the 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;
 Local $i&lt;br /&gt;
 ;Get a random number between 0 and 20&lt;br /&gt;
 Local $rnd = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $rnd&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then &lt;br /&gt;
         ; Resize the array&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&lt;br /&gt;
     ; Remember to update the count or last item&lt;br /&gt;
     $arr[0] = $i&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 result&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;, $rnd:=&amp;quot; &amp;amp; $rnd &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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10872</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10872"/>
		<updated>2012-11-08T21:32:04Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: /* Array UDF: array.au3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 it&#039;s index at 0.  So, the first element in the array referenced by a 0.&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. Ex:  An array with 3 elements has a last index of 2. &lt;br /&gt;
&lt;br /&gt;
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 a &amp;quot;out of bounds error&amp;quot;.&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 $i&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 3 - 1 construct used in the last sample looked strange.  It is not a good idea to hardcode size like that. So lets improve our sample a litle bit. &lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=3&lt;br /&gt;
 Local $i&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 is a bit cleaner. It is 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 you get the array from somewhere else.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax&lt;br /&gt;
 Local $i&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;
     Local $iMax = UBound($arr)&lt;br /&gt;
     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax)&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;
 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 StringSplit 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 a array containing data with a 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 $i&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 a 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 as 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 itterating with $arr[0] needs no other change than maintaining the correct &lt;br /&gt;
count in $arr[0]&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=10&lt;br /&gt;
 Local $i&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 itterations. If the array are to small it should automatically be increased. Before we dump the array to output, we should adjust the 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;
 Local $i&lt;br /&gt;
 ;Get a random number between 0 and 20&lt;br /&gt;
 Local $rnd = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $rnd&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then &lt;br /&gt;
         ; Resize the array&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&lt;br /&gt;
     ; Remember to update the count or last item&lt;br /&gt;
     $arr[0] = $i&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 result&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;, $rnd:=&amp;quot; &amp;amp; $rnd &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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
	<entry>
		<id>https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10865</id>
		<title>Arrays</title>
		<link rel="alternate" type="text/html" href="https://www.autoitscript.com/w/index.php?title=Arrays&amp;diff=10865"/>
		<updated>2012-11-08T20:41:06Z</updated>

		<summary type="html">&lt;p&gt;FlutterShy: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&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 it&#039;s index at 0.  So, the first element in the array referenced by a 0.&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. Ex:  An array with 3 elements has a last index of 2. &lt;br /&gt;
&lt;br /&gt;
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 a &amp;quot;out of bounds error&amp;quot;.&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 $i&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 3 - 1 construct used in the last sample looked strange.  It is not a good idea to hardcode size like that. So lets improve our sample a litle bit. &lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=3&lt;br /&gt;
 Local $i&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 is a bit cleaner. It is 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 you get the array from somewhere else.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax&lt;br /&gt;
 Local $i&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;
     Local $iMax = UBound($arr)&lt;br /&gt;
     ConsoleWrite(&amp;quot;Items in the array: &amp;quot; &amp;amp; $iMax)&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;
 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 StringSplit 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 a array containing data with a 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 $i&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 a 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 as 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 itterating with $arr[0] needs no other change than maintaining the correct &lt;br /&gt;
count in $arr[0]&lt;br /&gt;
&amp;lt;source lang=autoit&amp;gt;&lt;br /&gt;
 Local $iMax=10&lt;br /&gt;
 Local $i&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 itterations. If the array are to small it should automatically be increased. Before we dump the array to output, we should adjust the 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;
 Local $i&lt;br /&gt;
 ;Get a random number between 0 and 20&lt;br /&gt;
 Local $rnd = Random(0, 20, 1)&lt;br /&gt;
 For $i = 1 to $rnd&lt;br /&gt;
     ; Check that the array is big enough&lt;br /&gt;
     If UBound($arr) = $i Then &lt;br /&gt;
         ; Resize the array&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&lt;br /&gt;
     ; Remember to update the count or last item&lt;br /&gt;
     $arr[0] = $i&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 result&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;, $rnd:=&amp;quot; &amp;amp; $rnd &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 the 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;
 Local $i, $j&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;
But you can add dimensions, how many was not mentioned in the help files limits page as of writing. But drop me a note if you find a problem where it is easier 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: Then next line is supposed to be on one line&lt;br /&gt;
Local $arr[3][3][3][3] = [[[[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]]], _&lt;br /&gt;
		[[[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]], _&lt;br /&gt;
		[[1, 2, 3],[2, 3, 4],[3, 4, 5]],[[1, 2, 3],[2, 3, 4],[3, 4, 5]]]]&lt;br /&gt;
&lt;br /&gt;
Local $i, $j, $k, $l&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; _&lt;br /&gt;
						&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, again. You have to go through a variable to get access to the embedded array. &lt;br /&gt;
&lt;br /&gt;
Remember this. There are issues if you pass an array containing arrays into a function and the embedded array is changed inside that function. So, to conclude this, do not use arrays embedded in an array unless you absolutely have to, and are prepared to do rigorously testing to make sure your code work as you expect it to.&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;&lt;br /&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 $i , $j&lt;br /&gt;
   Local $dumy&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;!UPS, What happened? Expected an array&amp;quot; &amp;amp; @LF)&lt;br /&gt;
	EndIf &lt;br /&gt;
   Next&lt;br /&gt;
&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:&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Array1=$Array1 .&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;
$Array1[1]=&amp;quot;blabla&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;or&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;autoit&amp;quot;&amp;gt;&lt;br /&gt;
$Content=$Array1[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;
if $Array1 == $Array2 then $OK=&amp;quot;equal&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;I have the impressionthat such comparisions compare the memory adress of the arrays instead of the array elements values. And the adresses are always different for different arrays.&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
You have, instead to compare all elements one after the other. It might be a good idea to first compare arry 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), amoung 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;br /&gt;
== TODO ==&lt;br /&gt;
Update information about UBound($arr, 0).&lt;br /&gt;
Create a section with utility functions? Include _ArrayWalk by @Saunders(http://www.autoitscript.com/forum/index.php?s=&amp;amp;showtopic=53390&amp;amp;view=findpost&amp;amp;p=410283)?&lt;/div&gt;</summary>
		<author><name>FlutterShy</name></author>
	</entry>
</feed>