Concatenating Arrays
Posted: Sat Oct 10, 2015 1:44 pm
Hey guys,
I'd like to inquire about how I could concatenate arrays within livecode.
Here is what I'm trying to do specifically -
I have several arrays -
aryName - is a string
aryNum1 - is an integer
aryNum2 - is an integer
arySum - is an integer that is the sum of aryNum1 and aryNum2
aryTotal - is an integer that is the sum of all integers stored in arySum
Lets say my input is as follows -
(in the first index of the arrays)
aryName - Bob
aryNum1 - 7
aryNum2 - 7
arySum - (the sum of both, or 14)
(in the second index of the arrays)
aryName - John
aryNum1 - 8
aryNum2 - 2
arySum - (the sum of both, or 10)
aryTotal - the sum of both index values (14+10, or 24)
How could I concatenate this information into a format similar to:
Bob has 7 of the first item and 7 of the second item, or 14 items in total.
John has 8 of the first time and 2 of the second item, or 10 items in total.
The total number of items used is 24.
I've seen a few examples of the combine and split functions, but am not exactly sure how to use them in order to yield the results I am after.
The other thing I would like to mention, is that the number of indexes will be unknown - maybe one time the user may only have 2 as shown in my example above, and maybe another time the user will have 25 - so I will need to find a way to keep track of or query the number of indexes that are currently used in each array.
I really appreciate everyones help on this.
I'd like to inquire about how I could concatenate arrays within livecode.
Here is what I'm trying to do specifically -
I have several arrays -
aryName - is a string
aryNum1 - is an integer
aryNum2 - is an integer
arySum - is an integer that is the sum of aryNum1 and aryNum2
aryTotal - is an integer that is the sum of all integers stored in arySum
Lets say my input is as follows -
(in the first index of the arrays)
aryName - Bob
aryNum1 - 7
aryNum2 - 7
arySum - (the sum of both, or 14)
(in the second index of the arrays)
aryName - John
aryNum1 - 8
aryNum2 - 2
arySum - (the sum of both, or 10)
aryTotal - the sum of both index values (14+10, or 24)
How could I concatenate this information into a format similar to:
Bob has 7 of the first item and 7 of the second item, or 14 items in total.
John has 8 of the first time and 2 of the second item, or 10 items in total.
The total number of items used is 24.
I've seen a few examples of the combine and split functions, but am not exactly sure how to use them in order to yield the results I am after.
The other thing I would like to mention, is that the number of indexes will be unknown - maybe one time the user may only have 2 as shown in my example above, and maybe another time the user will have 25 - so I will need to find a way to keep track of or query the number of indexes that are currently used in each array.
I really appreciate everyones help on this.