Here is the function and a working example for finding the position (key) of an element with a certain value in a 2D Array.
The code:
function getPosOfValueInArray aArr, aVal
repeat with i = 1 to the number of lines in the keys of aArr
if aArr ["Idea ID"] = aVal then
return i
end if
end ...
Search found 5 matches
- Tue Mar 22, 2022 6:54 pm
- Forum: Getting Started with LiveCode - Complete Beginners
- Topic: finding an array element
- Replies: 26
- Views: 33870
- Tue Mar 01, 2022 9:49 am
- Forum: Getting Started with LiveCode - Complete Beginners
- Topic: Sort multidimensional array
- Replies: 87
- Views: 113708
Re: Sort multidimensional array
Guys, in the attached example I have tried all three algorithms posted above and couldn't make anyone work. I would appreciate editing the attached re-posting it if you can make any one of the three algorithms work. Just uncomment the CALL of the algorithm you wish to try out :D
--put sortArray ...
--put sortArray ...
- Tue Mar 01, 2022 8:54 am
- Forum: Getting Started with LiveCode - Complete Beginners
- Topic: How to retrieve a ROW from a 2D array
- Replies: 11
- Views: 6481
Re: How to retrieve a ROW from a 2D array
Hi Guys. I applied some of the advice above but I cannot get it to work. I attach a very simple program to show you that the combine does not seem to be working as expected. What i would really appreciate is FIXING it and sharing it....
Simply click Clear to empty the Grid
Click "Create 2 Array" to ...
Simply click Clear to empty the Grid
Click "Create 2 Array" to ...
- Mon Feb 28, 2022 10:58 pm
- Forum: Getting Started with LiveCode - Complete Beginners
- Topic: How to retrieve a ROW from a 2D array
- Replies: 11
- Views: 6481
How to retrieve a ROW from a 2D array
Assume an 2D array:
ID Group Label State
1 3 Financial 1
2 5 Other 1
3 6 Political 0
4 7 Civil 0
Question 1: How can I retrieve the data of a single Row?
Question 2: How can I get the Group element which is the first whose state is zero (in this case 6)?
Your help is truly appreciated. I have spent ...
ID Group Label State
1 3 Financial 1
2 5 Other 1
3 6 Political 0
4 7 Civil 0
Question 1: How can I retrieve the data of a single Row?
Question 2: How can I get the Group element which is the first whose state is zero (in this case 6)?
Your help is truly appreciated. I have spent ...
- Mon Feb 28, 2022 10:10 pm
- Forum: Getting Started with LiveCode - Complete Beginners
- Topic: How to retrieve a column array from a 2-D array?
- Replies: 18
- Views: 15148
Re: How to retrieve a column array from a 2-D array?
I still don't get it how I can retrieve a ROW from the 2D array. Any help there? How can we edit the function for GetArrayColumn to create a function GetArrayRow? Rows do not have names -;)