# ArrayFindAll on 2D Array Help

## Recommended Posts

Appreciate some help with this

Initially I had a [6][3] array & ArrayFindAll works

Then I made it a [6][4] & then a [6][9] arrays & ArrayFindAll doesn't works @error = 6 - \$vValue was not found in array

```#include <array.au3>
Global \$aArray[6][3] = [[1, "A", "1111"], [2, "B", "2222"], [3, "C", "3333"], [4, "D", "4444"], [5, "E", "5555"], [6, "F", "6666"]]
;Global \$aArray[6][4] = [[1, "A", "1111","G"], [2, "B", "2222", "M"], [3, "C", "3333", "S"], [4, "D", "4444", "Y"], [5, "E", "5555", "B1"], [6, "F", "6666", "C1"]]
;Global \$aArray[6][9] = [[1, "A", "1111", "G", "H","I","J","K","L"], [2, "B", "2222", "M","N", "O","P","Q", "R"], [3, "C", "3333", "S", "T","U","V","W","X"], [4, "D", "4444", "Y", "Z","A1","A2","A3","A4"], [5, "E", "5555", "B1", "B2","B3","B4","B5","B6"], [6, "F", "6666", "C1", "C2","C3","C4","C5","C6"]]
_ArrayDisplay(\$aArray)
Local \$aiResult  = _ArrayFindAll(\$aArray, "5555",0,0,0,1,3)
If @error = 0 Then
_ArrayDisplay(\$aiResult)
Else
MsgBox(0,"","Error " & @error)
EndIf
Exit```

##### Share on other sites

The array columns are zero based, and unfortunately for your script, if the column searched in is past the end of the array, it corrects your search to be the last column. So when you were searching the 3 column of the array in the 6/3 array, it was actually asking to search the 4th column, since there is no 4th column, it was auto-corrected to search the 3rd. When there actually is a 4th column, the auto-correction doesn't happen, and it searches in the 4th column (column order 0,1,2,3,4). Change the 3 in _arrayfindall to 2, and it works correctly.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

##### Share on other sites

Thanks BrewMan, for this and many of your other post that have helped me out.

I'm doing the face palm..lol

##### Share on other sites

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

## Create an account

Register a new account

• ### Similar Content

• By jmp
Script running good but error in line 7.
When i run this script :
#include <IE.au3> #include <Array.au3> \$oIE = _IEAttach ("Shop") \$oTable = _IETableGetCollection (\$oIE, 1) \$aTableData = _IETableWriteToArray (\$oTable) For \$inumber = 1 To UBound(\$aTableData) -1 \$table = \$aTableData[4][\$inumber] MsgBox(0, "", \$table) Next I got Error: array variable has incorrect number of subscripts or subscript dimension range exceeded

• Good morning guys, i hope that you're all well.
guys, i have a problem and i hope that you can help me
i've created an 3d array
the array Contain a Categories info
as folow
\$array[n][0][0] = Categorie name
\$array[n][0][1] = Categorie file path
\$array[n][0][2] = Categorie contents number
in my tool i want to add an option to delete a Category
as you know the Categorie mean that must delete a region from the array
when i tried to use _arrayDelete
with the 2d array it work well
but here i couldn't find any way to do that, can any one help me please?

i tried to create a function that read a folder files to 3d array
e.g
\$array[n][0][0] = ctName
\$array[n][0][1] = ctFilePath
\$array[n][0][2] = crtsections number
\$array[n][m][0] = KeyName
\$array[n][m][1] = KeyVal
\$array[n][m][2] = keySectionName

that the array
when i put one file into the folder all things work fine
but when i put more than one file
the last file worked fine but the others only the first key is showing
please can you help me to correct this problem
here is the example with the folder

array3d.zip

• good morning everybody.
today i liked to share an small example with you
which it an function to read the registry values as an array
the result array is 2d array witch
\$a_array[n][0] = value name
\$a_array[n][1] = value Data
\$a_array[0][0] = values count
here's the function

#include <Array.au3> #include <WinAPIReg.au3> #include <APIRegConstants.au3> Local \$a_array = _RegReadToArray("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run") If @error Then     MsgBox(16, "error", @error)     Exit EndIf _ArrayDisplay(\$a_array) Func _RegReadToArray(\$s_RegKey)     Local \$a_KeySplitInfo = StringSplit(\$s_RegKey, "\\", 2)     If UBound(\$a_KeySplitInfo) <= 1 Then         \$a_KeySplitInfo = StringSplit(\$s_RegKey, "\", 2)         If UBound(\$a_KeySplitInfo) <= 1 Then Return (1, 1, 0)     EndIf     Local \$H_KeyInfo = "", \$s_RegKeyInfo = ""     Switch \$a_KeySplitInfo[0]         Case "hklm", "HKEY_LOCAL_MACHINE", "hklm64", "HKEY_LOCAL_MACHINE64"             \$H_KeyInfo = \$HKEY_LOCAL_MACHINE         Case "hkCu", "HKEY_CURRENT_USER", "hkCU64", "HKEY_CURRENT_USER64"             \$H_KeyInfo = \$HKEY_CURRENT_USER         Case "hkCr", "HKEY_CLASSES_ROOT", "HKCR64", "HKEY_CLASSES_ROOT64"             \$H_KeyInfo = \$HKEY_CLASSES_ROOT         Case "HKU", "HKEY_USERS", "HKU64", "HKEY_USERS64"             \$H_KeyInfo = \$HKEY_USERS         Case Else             Return SetError(2, 2, 0)     EndSwitch     _ArrayDelete(\$a_KeySplitInfo, 0)     \$s_RegKeyInfo = _ArrayToString(\$a_KeySplitInfo, "\")     Local \$H_KeyInfoOpen = _WinAPI_RegOpenKey(\$H_KeyInfo, \$s_RegKeyInfo, \$KEY_READ)     Local \$A_KeyInfo = _WinAPI_RegQueryInfoKey(\$H_KeyInfoOpen)     If @error Then Return SetError(1, 1, 0)     _WinAPI_RegCloseKey(\$H_KeyInfoOpen)     Local \$A_RegVal[\$A_KeyInfo[2] + 1][2]     Local \$iV = 1, \$s_RegRead = ""     While 1         \$s_RegVal = RegEnumVal(\$s_RegKey, \$iV)         If @error <> 0 Then ExitLoop         \$s_RegRead = RegRead(\$s_RegKey, \$s_RegVal)         If Not (@error) Then             \$A_RegVal[\$iV][0] = \$s_RegVal             \$A_RegVal[\$iV][1] = \$s_RegRead         EndIf         \$iV += 1     WEnd     \$A_RegVal[0][0] = UBound(\$A_RegVal) - 1     If \$A_RegVal[0][0] >= 1 Then         Return \$A_RegVal     Else         Return SetError(3, 3, 0)     EndIf EndFunc   ;==>_RegReadToArray
i hope you benefit from it
with my greetings

• Hi, first of all thanks to all the guys who always help people in the forums, I wouldn't be able to do anything if wasn't for your help, even if I don't ask it myself.

I've created this code to get some info on a monitoring network on my work. It relays on _IETableGetCollection and _IETableWriteToArray.
It works well, but take around 3:25 minutes to get the info from 28 pages (some of them are large and take longer to load, but most of them are small and fast).
My question is if you see a way to get the program to go faster...

I've tried to make it easy for you to understand and edited somethings with sensitive info.
(Some of the pages doesn't have the black divider with MIRA in the end, so I need to search if it is there or not.)

#include <IE.au3> #include <array.au3> Local \$oIE = _IECreate("about:blank", 0, 0) Local \$paginas[28] = [89, 90, 91, 92, 93, 96, 105, 113, 119, 125, 126, 129, 131, 133, 135, 137, 139, 140, 141, 144, 145, 146, 148, 149, 150, 151, 158, 159] Local \$Datos_array[0][2] Local \$oTable Local \$tabla Local \$aux_x = 1 Local \$ar = 1 Local \$Numtables_datos = 0 MsgBox(0, "asd", "asd") For \$pag = 0 To UBound(\$paginas) - 1 Step 1 _IENavigate(\$oIE, "<WEBSITE URL>" & \$paginas[\$pag]) ; <<< the pages to load are always the same except for the last digits. _ArrayAdd(\$Datos_array, \$paginas[\$pag] & "|" & "Entrante", 0, "|") ; <<<<<<<<<<<<<<<< adds the page number toarray [0, 0] ;############################################ START counts amount of tables with traffic \$oTable = _IETableGetCollection(\$oIE) Local \$iNumTables = @extended For \$i = 3 To \$iNumTables - 2 Step 1 \$oTable = _IETableGetCollection(\$oIE, \$i) \$nomb_tabla2 = _IETableWriteToArray(\$oTable) ; <<<<<<<< TABLE TO ARRAY. \$string2 = StringStripWS(\$nomb_tabla2[1][0], 8) If \$string2 <> "MIRA" Then \$Numtables_datos = \$Numtables_datos + 1 Next \$tabla_End = \$iNumTables - \$Numtables_datos ;############################################ FIN \$tabla_Start = 4 \$tabla_trafico = 2 For \$for = 1 To \$Numtables_datos Step 1 \$oTable = _IETableGetCollection(\$oIE, \$tabla_Start - 1) ; <<<<<<<<<<< NAME OF THE TABLE; row2 = mira \$nomb_tabla = _IETableWriteToArray(\$oTable) ; <<<<<<<< TABLE TO ARRAY ;########################################### ADDS the traffic number into the row \$string = StringStripWS(\$nomb_tabla[1][0], 8) If \$string == "MIRA" Then ;si o si pasa por aca 1 vez _ArrayAdd(\$Datos_array, \$nomb_tabla[0][0]) \$nomb_aux = \$nomb_tabla[0][0] \$aux_x = 1 \$tabla_trafico = \$tabla_trafico + 2 Else ;esto deberia ser por row _ArrayAdd(\$Datos_array, \$nomb_aux & " " & \$aux_x) \$aux_x = \$aux_x + 1 \$tabla_trafico = \$tabla_trafico + 1 EndIf \$oTable = _IETableGetCollection(\$oIE, \$tabla_trafico) Local \$aTableData = _IETableWriteToArray(\$oTable) \$bps = _ArrayToString(\$aTableData, "|", 0, 0, @CRLF, 0, 0) \$bps = StringRight(\$bps, 5) \$bps = StringLeft(\$bps, 4) \$trafico_actual = _ArrayToString(\$aTableData, "|", 0, 0, @CRLF, 2, 2) If \$bps == "Gbps" Then \$trafico_actual = \$trafico_actual * 1000 If \$bps == "Kbps" Then \$trafico_actual = \$trafico_actual / 1000 \$Datos_array[\$ar][1] = \$trafico_actual \$ar = \$ar + 1 If \$string == "MIRA" Then \$tabla_Start = \$tabla_Start + 2 Else \$tabla_Start = \$tabla_Start + 1 EndIf Next \$ar = \$ar + 1 ;~ ############# CAÍDA ############ ;~ If \$actual_entrante = 0 Then ;~ \$xxx = 0 ;~ Do ;~ MsgBox(0, "Tráfico Caído", \$paginas[\$i], 5) ;~ \$xxx = \$xxx + 1 ;~ Until \$xxx = 10 ;~ EndIf ;~ ############# CAÍDA ############. Local \$Numtables_datos = 0 Next _ArrayDisplay(\$Datos_array, "Array display") _IEQuit(\$oIE) Thanks!!

monitoria.html
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...