P0LarWolF Posted January 22, 2023 Share Posted January 22, 2023 (edited) Hi folks. I have some trouble with writing Array to an Variable. Here is the code: #include <Array.au3> ; Create an 2D-Array Local $TV_1[11][2] = [["TV1", 0], ["TV2", 1], ["TV3", 0], ["TV4", 1], ["TV5", 0], ["TV6", 1], ["TV7", 0], ["TV8", 1], ["TV9", 0], ["TV10", 1], ["TV11", 0]] _ArrayDisplay($TV_1, "2D Array") ; Now search vor " 0 " in Sub-Index 1 of above 2D-Array. Columns only Local $aiResult = _ArrayFindAll($TV_1, 0, Default, Default, Default, Default, 1, False) _ArrayDisplay($aiResult, "Result") ; Ok. The "0" was found on positions: 0, 2, 4, 6, 8, 10. ; So far so good ; Now i check the dimension of the array. It should be max. 6! If Ubound($aiResult) = 6 Then ; And here i stuck. I want to "write" the found positions(0, 2, 4, 6, 8, 10) position by position to an variable like $TV and transfer it to a function. For ???? To ???? _Example($TV) Next EndIf Func _Example($TV) If $TV = 0 Then ConsoleWrite("TV1" & @CRLF) If $TV = 1 Then ConsoleWrite("TV2" & @CRLF) If $TV = 2 Then ConsoleWrite("TV3" & @CRLF) If $TV = 3 Then ConsoleWrite("TV4" & @CRLF) If $TV = 4 Then ConsoleWrite("TV5" & @CRLF) If $TV = 5 Then ConsoleWrite("TV6" & @CRLF) If $TV = 6 Then ConsoleWrite("TV7" & @CRLF) If $TV = 7 Then ConsoleWrite("TV8" & @CRLF) If $TV = 8 Then ConsoleWrite("TV9" & @CRLF) If $TV = 9 Then ConsoleWrite("TV10" & @CRLF) If $TV = 10 Then ConsoleWrite("TV11" & @CRLF) EndFunc Many thx in advance. Edited January 22, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
water Posted January 22, 2023 Share Posted January 22, 2023 Did you have a look at the help file to see how "For...In...Next" works? P0LarWolF 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 22, 2023 Author Share Posted January 22, 2023 (edited) yes, i have. but unfortunately i don't really understand it, at the moment. I take a look again. aaaaah. damn. solved For $TV in $aiResult _Example($TV) Next Edited January 22, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
water Posted January 22, 2023 Share Posted January 22, 2023 The example provided in the help file shows how to process an array. So your script should look like: For $iNumber In $aiResult _Example($iNumber) Next or For $iNumber = 0 To UBound($aiResult) - 1 _Example($iNumber) Next P0LarWolF 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 22, 2023 Author Share Posted January 22, 2023 thx alot. i had edit my second post. the first example is that what i need. Link to comment Share on other sites More sharing options...
water Posted January 22, 2023 Share Posted January 22, 2023 NB: Shouldn't this line ; Now i check the dimension of the array. It should be max. 6! If Ubound($aiResult) = 6 Then be ; Now i check the dimension of the array. It should be max. 6! If Ubound($aiResult) <= 6 Then Because "max. 6" means 6 or lower to me P0LarWolF 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 22, 2023 Author Share Posted January 22, 2023 (edited) You're right, but Quote ;It should be max. 6! was wrong. My mistake. I meant it should be exactly 6. Edited January 22, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
water Posted January 22, 2023 Share Posted January 22, 2023 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) Good morning. Is there a easy way to update all the values inside my 2-D Array. I mean only the values in index 1 ( all the zeros). #include <Array.au3> ; Create an 2D-Array Local $TV_Array[11][2] = [["TV1", 0], ["TV2", 0], ["TV3", 0], ["TV4", 0], ["TV5", 0], ["TV6", 0], ["TV7", 0], ["TV8", 0], ["TV9", 0], ["TV10", 0], ["TV11", 0]] _ArrayDisplay($TV_Array, "2D Array") ; Now search vor " 0 " in Sub-Index 1 of above 2D-Array. Columns only Local $aiResult = _ArrayFindAll($TV_Array, 0, Default, Default, Default, Default, 1, False) _ArrayDisplay($aiResult, "Result") ; Ok. The "0" was found on positions: 0, 2, 4, 6, 8, 10. ; So far so good ; Now i check the dimension of the array. It should be exactly 6! If Ubound($aiResult) = 6 Then ; Write the found positions(0, 2, 4, 6, 8, 10) position by position to an variable $TV and transfer function _Example(). For $TV in $aiResult _Example($TV) Next EndIf Func _Example($TV) If $TV = 0 Then ConsoleWrite("TV1" & @CRLF) If $TV = 1 Then ConsoleWrite("TV2" & @CRLF) If $TV = 2 Then ConsoleWrite("TV3" & @CRLF) If $TV = 3 Then ConsoleWrite("TV4" & @CRLF) If $TV = 4 Then ConsoleWrite("TV5" & @CRLF) If $TV = 5 Then ConsoleWrite("TV6" & @CRLF) If $TV = 6 Then ConsoleWrite("TV7" & @CRLF) If $TV = 7 Then ConsoleWrite("TV8" & @CRLF) If $TV = 8 Then ConsoleWrite("TV9" & @CRLF) If $TV = 9 Then ConsoleWrite("TV10" & @CRLF) If $TV = 10 Then ConsoleWrite("TV11" & @CRLF) EndFunc I tried nested for/next loops like this, but this function updates both indexes. #Include <Array.au3> Local $a[2][2] = [[0,1],[10,20]] For $i = 0 to UBound($a)-1 For $j = 0 to UBound($a, 2)-1 $a[$i][$j] += 5 Next Next _ArrayDisplay($a) thx in davance Edited January 23, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) Ok. This work. But the problem is that all values in column one will be updated to a " 1 ". In my case every index in column one should get an different value written by an another function For $i = 0 To UBound($TV) - 1 $TV[$i][1] = 1 ;or what else Next thx Edited January 23, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
water Posted January 23, 2023 Share Posted January 23, 2023 Then call the other function and assing the return value to your array. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 23, 2023 Author Share Posted January 23, 2023 Hi. Here is my solution for the moment. What do you think? Func _ReDimArray() Local $i = 0 ReDim $TV_Array[$i + 11][2] $TV_Array[$i][1] = 11 $i += 1 $TV_Array[$i][1] = 12 $i += 1 $TV_Array[$i][1] = 13 $i += 1 $TV_Array[$i][1] = 14 $i += 1 $TV_Array[$i][1] = 15 $i += 1 $TV_Array[$i][1] = 16 $i += 1 $TV_Array[$i][1] = 17 $i += 1 $TV_Array[$i][1] = 18 $i += 1 $TV_Array[$i][1] = 19 $i += 1 $TV_Array[$i][1] = 20 $i += 1 $TV_Array[$i][1] = 21 $i += 1 _ArrayDisplay($TV_Array, "2D Array") EndFunc This way also work For $i = 0 To UBound($TV_Array) - 1 If $i = 0 Then $TV_Array[$i][1] = 4 Elseif $i = 1 Then $TV_Array[$i][1] = 100 EndIf ; and so on Next _ArrayDisplay($TV_Array, "2D Array") I think the fist solution is ab bit shorter, withot If...ElseIf..Then Link to comment Share on other sites More sharing options...
water Posted January 23, 2023 Share Posted January 23, 2023 What is your goal? Do you want to call the function to extend the array by 11 rows and initialize the second columns with $i + 11? So after the first call the array would have 11 rows, after the second call 22 and so on. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 23, 2023 Author Share Posted January 23, 2023 (edited) The Array should have always 11 rows. I just want to update every value row by row in column 1. Values(in my case strings) in column 0 are always the same That's the starting Array Global $TV_Array[11][2] = [["TV1", 0], ["TV2", 1], ["TV3", 1], ["TV4", 0], ["TV5", 0], ["TV6", 1], ["TV7", 0], ["TV8", 1], ["TV9", 0], ["TV10", 1], ["TV11", 0]] Edited January 23, 2023 by P0LarWolF Link to comment Share on other sites More sharing options...
water Posted January 23, 2023 Share Posted January 23, 2023 Something like this. #include <Array.au3> Global $aTV_Array[11][2] = [["TV1", 0], ["TV2", 0], ["TV3", 0], ["TV4", 0], ["TV5", 0], ["TV6", 0], ["TV7", 0], ["TV8", 0], ["TV9", 0], ["TV10", 0], ["TV11", 0]] _ArrayDisplay($aTV_Array) InitArray($aTV_Array) _ArrayDisplay($aTV_Array) Func InitArray(ByRef $aArray) Local $iOffset = 11 For $i = 0 To UBound($aArray, 1) - 1 $aArray[$i][1] = $i + $iOffset Next EndFunc ;==>InitArray P0LarWolF 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
P0LarWolF Posted January 23, 2023 Author Share Posted January 23, 2023 Great! thx Link to comment Share on other sites More sharing options...
Skysnake Posted January 30, 2023 Share Posted January 30, 2023 @P0LarWolF please see this? Arrays - AutoIt Wiki (autoitscript.com) S Skysnake Why is the snake in the sky? 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