Phaser Posted September 6, 2010 Share Posted September 6, 2010 Hi Guys I am checking data with array find all which either gives me -1, nothing found or retunrs an array of how many it finds. I will be getting 1 2 3 or 4 indexes returned, how can I see how many indexes are returned as I only want to work with arrays with 2 or more indexes? Link to comment Share on other sites More sharing options...
RagsRevenge Posted September 6, 2010 Share Posted September 6, 2010 Hi GuysI am checking data with array find all which either gives me -1, nothing found or retunrs an array of how many it finds. I will be getting 1 2 3 or 4 indexes returned, how can I see how many indexes are returned as I only want to work with arrays with 2 or more indexes?Do a search for UBound in the Help file, and your questions will be answered. Link to comment Share on other sites More sharing options...
Phaser Posted September 6, 2010 Author Share Posted September 6, 2010 Many thanks RagsRevenge, I see in the remarks section it mentions about the number returned being one greater, I know you count arrays from 0 but the number returned is actually 1 if index 0 contains data so am I correct that the below would be the numbers returned by UBound $array [5] = [39] UBound would return 1 $array [5] = [39,96] UBound would return 2 $array [5] = [39,96,177] UBound would return 3 As this is what its doing for me, there's no problem with that, just want to make sure. Link to comment Share on other sites More sharing options...
Fubarable Posted September 6, 2010 Share Posted September 6, 2010 (edited) When you created a small program and tested it, what was the result? If there's still ambiguity, please post your test program so we can see precisely what you're doing with functioning code. Luck! Edited September 6, 2010 by Fubarable Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 7, 2010 Share Posted September 7, 2010 (edited) Many thanks RagsRevenge, I see in the remarks section it mentions about the number returned being one greater, I know you count arrays from 0 but the number returned is actually 1 if index 0 contains data so am I correct that the below would be the numbers returned by UBound $array [5] = [39] UBound would return 1 $array [5] = [39,96] UBound would return 2 $array [5] = [39,96,177] UBound would return 3 As this is what its doing for me, there's no problem with that, just want to make sure. You need to work with valid syntax to start with. Write an actual short script you can actually run. What you posted will cause errors and fail miserably. Perhaps you are confusing AutoIt with another language in the way you tried to call array elements. In AutoIt every dimension declared MUST be specified with an index for EVERY reference. One Dimensional Array: Declaring it: Global $array[50] Setting a value: $array[5] = 1234 Last element: $array[49] Ubound: - Ubound($array, 0) returns 1 (there is one dimension) - Ubound($array) or Ubound($array, 1) returns 50 (there are 50 elements) Three Dimensional Array: Declaring it: Global $array[50][35][200] Setting a value: $array[5][26][177] = 1234 Last element: $array[49][34][199] Ubound: - Ubound($array, 0) returns 3 (there are three dimensions) - Ubound($array) or Ubound($array, 1) returns 50 (there are 50 elements in the first dimension) - Ubound($array, 2) returns 35 (there are 35 elements in the second dimension) - Ubound($array, 3) returns 200 (there are 200 elements in the third dimension) Edit: Typo Edited September 7, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
guinness Posted September 7, 2010 Share Posted September 7, 2010 (edited) I normally reserve row 0 for adding the number of elements/columns and updating when necessary. I do this because I read that if you have 1000's of elements Ubound can be come very slow! e.g. 1D Array - $Array[0] = 50 is the vertical number of elements & since it's a single column I don't need to know the number of columns. e.g. 2D Array - $Array[0][0] = 50 is the vertical number of elements & $Array[0][1] = 3 is the number of columns. e.g. 3D Array - Not required yet! Then when I add/delete an array element I update the appropriate integer by using $Array[0] += 1 / $Array[0] -= 1 OR $Array[0][0] += 1 / $Array[0][0] -= 1 For loops are also made easier, because all elements start from 1 upwards and not the illogical 0+. For $i = 1 To $Array[0][0] ; Same as using Ubound($Array, 1) - 1 ConsoleWrite($Array[$i][0] & @CRLF) Next Take a look at StringSplit() to get an idea of how the $Array is returned. Hope this is clear. Edited September 7, 2010 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
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