SlowCoder74 Posted April 25, 2012 Author Share Posted April 25, 2012 Local $aArray[1] = [0] ; Shouldn't it be this then?Can you explain what this is supposed to do? Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2012 Share Posted April 25, 2012 (edited) It is a standard 0 based array, the value stored at the first element [0] is 0. it can be manipulated to hold some other value ... $aArray[0] = 55764 ;etc... I agree, your needs are very confusing. EDIT: In the alpha version, you can create an array like so... Local $aArray[] Edited April 25, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Mechaflash Posted April 25, 2012 Share Posted April 25, 2012 (edited) from post #20 it just looks like you're asking "why can't [0] element be used" when it can? #include Local $aArray[1] ; Declare array with 1 element $aArray[0] = "zero element" ; "zero element" exists at element [0] _ArrayDisplay($aArray) ; Shows array output So if you wanted [0] and [1] you would declare it as Local $aArray[2] instead. It's just counting the elements starting from 0, so the offset will always be -1. Edited April 25, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 25, 2012 Author Share Posted April 25, 2012 (edited) It is a standard 0 based array, the value stored at the first element [0] is 0. it can be manipulated to hold some other value ... $aArray[0] = 55764 ;etc... No, local aArray[1] = [0] Unless I'm reading it wrong, it says to me that this is a 1-based array. not a 0-based array. And I don't understand what the [0] part all by itself means. I agree, your needs are very confusing. Why is it confusing to want to be able to assign a value to $aArray[0]? That is a 0-based array, right? I'm a builder. Mr. Element #1 comes to me to build a house for him. I decide I want to give Mr. Element #1 house address 0. So I build the house ($aArray[0]), and name the house Mr. Element #1's name. ($aArray[0] = "Mr. Element #1"). This is not EXACTLY what my initial post was for, but the essence is the same. Edited April 25, 2012 by SlowCoder74 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 25, 2012 Moderators Share Posted April 25, 2012 SlowCoder74,Arrays in AutoIt always start with the [0] element. But when you declare an array you pass the total number of elements. So declaring an array like this:Global $aArray[1] = [9999]produces a single element array like this:Element Value [0] 9999That is why UBound will return a value of 1 for this array.Does that make it clear? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted April 25, 2012 Share Posted April 25, 2012 Seems like Melba23 got there before I did. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Kip Posted April 25, 2012 Share Posted April 25, 2012 (edited) So if you wanted [0] and [1] you would declare it as Local $aArray[2] instead. It's just counting the elements starting from 0, so the offset will always be -1. You start counting the elements from 1. Their index, however, starts at 0. E.g. the first element has an index of 0. You can create an array like this: Local $array[1] That creates a array with one element (that can be accessed with index 0). However, sometimes you may want to create an array and assign some initial values in one line, like this: Local $array[3] = ["how", "are", "you"] This creates an array with 3 elements and with the elements already filled in: 0: "how", 1: "are", 2: "you" Edited April 25, 2012 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 25, 2012 Author Share Posted April 25, 2012 SlowCoder74, Arrays in AutoIt always start with the [0] element. But when you declare an array you pass the total number of elements. So declaring an array like this: Global $aArray[1] = [9999] produces a single element array like this: Element Value [0] 9999 That is why UBound will return a value of 1 for this array. Does that make it clear? M23 Yes! That does make it clear. I'll have to adjust my thinking for this difference. Link to comment Share on other sites More sharing options...
JohnOne Posted April 25, 2012 Share Posted April 25, 2012 So you declare it like so Local $aArray[1] And you access and manipulate it like so $aArray[0] = "whatever" AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
SlowCoder74 Posted April 25, 2012 Author Share Posted April 25, 2012 Thank you all, for sticking with me through this. Link to comment Share on other sites More sharing options...
LuI Posted June 19, 2012 Share Posted June 19, 2012 Wow, that's impressive: I found a 'problem' in AutoIT and it is fixed beforehand, allthough still in alpha-state ;-) Guys, I wanted to crawl through a tree in a filesystem an do something with special sub-dirs. Those can show up in any position within the tree. What I did (with LabVIEW) was creating an $array_of_pathes and initializing it by the start path. Than While Ubound($array_of_pathes) ; is not empty $ThisPath = _arrayPop($array_of_pathes) ; remove last element $SubDirs=_FileListToArray($array_of_pathes, "*", 2) ; process elements of $SubDirs and append all elements to $array_of_pathes ; this may add some new elements WEND Rewriting it to AutoIT caused an runtime error because, at the beginning, the initialized array got emptied by the _arrayPop, which causes IsArray($array_of_pathes) to return 0. While this can be avoided by introducing another element at index 0 and adopting the tests, it shows that at this time AutoIT does not support empty arrays. If you change that behaviour you should definitely check all the UDF in _array and provide proper warnings about the changed behaviour. Nevertheless introducing empty arrays is a good idea IMHO! Thanx for your work! -- Greetings from Germany! Dr. Uwe Frenz Link to comment Share on other sites More sharing options...
jchd Posted June 19, 2012 Share Posted June 19, 2012 (edited) This is partly wrong: AutoIt does support empty arrays. It's just that you can't create empty arrays from within AutoIt, but they may result from calls to COM objects. So indeed, the best way to deal with the case is to test explicitely.EDIT: as Melba pointed out! Edited June 19, 2012 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 19, 2012 Moderators Share Posted June 19, 2012 jchd,You meant to say that you CANNOT create empty arrays from within AutoIt - I hope. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 19, 2012 Share Posted June 19, 2012 So I was right. If you change that behaviour If? We got empty arrays in 3.3.9.5 Local $avArray[0] ConsoleWrite(IsArray($avArray) & @LF) ConsoleWrite(UBound($avArray) & @LF) 1 0 @jchd & Melba Mmmk. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
jchd Posted June 20, 2012 Share Posted June 20, 2012 Ah, I always forget the alpha is public! This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 20, 2012 Share Posted June 20, 2012 We still need someone to go through the _Array() functions and check and fix compatibility with empty arrays if anyone is interested .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 20, 2012 Moderators Share Posted June 20, 2012 AdmiralAlkex, Mea culpa. But how many members use the 3.3.9.5 alpha release? I confess I do not so that I do not (overly) confuse anyone who asks for help by suggesting solutions outside the current release (and beta if I must). M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 20, 2012 Share Posted June 20, 2012 AdmiralAlkex,Mea culpa. But how many members use the 3.3.9.5 alpha release? I confess I do not so that I do not (overly) confuse anyone who asks for help by suggesting solutions outside the current release (and beta if I must). M23I suppose you are right, but the alpha happens to be the best place to get empty arrays for now so....Beards. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Mechaflash Posted June 20, 2012 Share Posted June 20, 2012 (edited) Can AutoIt tell me the meaning of life?Yes... but that's not until version 12.4.8.3. Edited June 20, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now