Array Problem -LC 7.0.1
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Array Problem -LC 7.0.1
My array doesn't appear to be set up the way it should.
(Tried to insert an image)
.........1
1........ 0
2......... 4
i.e the first element doesn't have an index number
but accepts data but isn't really the first element.
The first one is the second one with index 1.
(What about "Whose on next"!)
My problem or is it LC?
(Mod because my representation of the array didn't appear
in the post as in the preview)
(Tried to insert an image)
.........1
1........ 0
2......... 4
i.e the first element doesn't have an index number
but accepts data but isn't really the first element.
The first one is the second one with index 1.
(What about "Whose on next"!)
My problem or is it LC?
(Mod because my representation of the array didn't appear
in the post as in the preview)
Last edited by RossG on Mon Nov 09, 2015 12:21 pm, edited 2 times in total.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Array Problem -LC 7.0.1
Hi.
How did you make this array?
Craig Newman
How did you make this array?
Craig Newman
Re: Array Problem -LC 7.0.1
What is the result of:
??
Code: Select all
put the keys of my_array
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Array Problem -LC 7.0.1
I made the array with
repeat with i = 1 to 36
put 0 into theArray
end repeat.
repeat with i = 1 to 36
put 0 into theArray
end repeat.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Array Problem -LC 7.0.1
I had a thought that my prog. might have tried to put a number
into array[0] but have watched the array being set up in the
debugger and the ghost element appears after the 36 real ones.
So it's not being done by my prog.
into array[0] but have watched the array being set up in the
debugger and the ghost element appears after the 36 real ones.
So it's not being done by my prog.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Array Problem -LC 7.0.1
What does the code used to verify the array look like?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Array Problem -LC 7.0.1
Using this code:
I get
No problem for me.
Moreover this code:
returns 36.
Code: Select all
repeat with i = 1 to 36
put 0 into theArray[i]
end repeat
put the keys of theArray into temp
sort numeric temp
put temp
Code: Select all
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Moreover this code:
Code: Select all
repeat with i = 1 to 36
put 0 into theArray[i]
end repeat
put the keys of theArray into temp
put the number of lines of temp
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: Array Problem -LC 7.0.1
Hi.
All you have written, aside from the first post, is as it should be. Can you duplicate the result you got initially, with the missing first key?
As an aside, you have discovered, at least for me, that the sortDirection can be placed either before or after the container reference. Anyone else know this?
Craig
All you have written, aside from the first post, is as it should be. Can you duplicate the result you got initially, with the missing first key?
As an aside, you have discovered, at least for me, that the sortDirection can be placed either before or after the container reference. Anyone else know this?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Array Problem -LC 7.0.1
I wonder if the erroneous output might be the result of having two arguments for the combine command provided in the wrong order.
combine tVarA with tab and return
...will yield something that looks like the OP's example, but:
combine tVarA with return and tab
...will produce something more like what's expected.
combine tVarA with tab and return
...will yield something that looks like the OP's example, but:
combine tVarA with return and tab
...will produce something more like what's expected.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Array Problem -LC 7.0.1
I've tried the same code in Rev 3.0 and it produces
the correct result.
the correct result.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Array Problem -LC 7.0.1
What does the code look like?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Array Problem -LC 7.0.1
ForthWorld
repeat with i = 1 to 36
put 0 into theArray
end repeat
repeat with i = 1 to 36
put 0 into theArray
end repeat
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Array Problem -LC 7.0.1
Stranger and stranger.
I opened the one-button prog I did with Rev 3
to initialize the array in LC and it makes the
array correctly.
As for getting the index of the elements in the array
I think I'll settle for putting them into theArray[1] and
the other data into theArray[2].
Later:
I've set up the array successfully without putting 0 into
each element. One of those mysteries that may never
be solved.
Thank you all for your efforts.
I opened the one-button prog I did with Rev 3
to initialize the array in LC and it makes the
array correctly.
As for getting the index of the elements in the array
I think I'll settle for putting them into theArray[1] and
the other data into theArray[2].
Later:
I've set up the array successfully without putting 0 into
each element. One of those mysteries that may never
be solved.
Thank you all for your efforts.
Last edited by RossG on Mon Nov 09, 2015 9:03 pm, edited 1 time in total.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Array Problem -LC 7.0.1
Hi.
This is what you posted before. This yields an array of 36 keys, each with a "0" as its associated element. Try:
Works just fine. So are you saying that in a later version of LC, a similar handler loses the first key?
Craig
This is what you posted before. This yields an array of 36 keys, each with a "0" as its associated element. Try:
Code: Select all
on mouseUp
repeat with i = 1 to 36
put 0 into theArray[i]
end repeat
combine theArray with return and comma
sort theArray numeric
put theArray into fld 1 --or whatever
end mouseUp
Craig
Re: Array Problem -LC 7.0.1
Craig
I'll not spend any time trying to solve this mystery.
Have to get on with my coding.
Later: I think my problem was caused by trying to delete
the array as it would be generated afresh on the next cycle.
I tried to put "" into each element.
Now, how do I "neutralize" the array?
delete array36
doesn't work.
I'll not spend any time trying to solve this mystery.
Have to get on with my coding.
Later: I think my problem was caused by trying to delete
the array as it would be generated afresh on the next cycle.
I tried to put "" into each element.
Now, how do I "neutralize" the array?
delete array36
doesn't work.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.