Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
edwardeddyus
- Posts: 10
- Joined: Mon Mar 25, 2013 7:17 pm
Post
by edwardeddyus » Wed Jul 12, 2017 12:46 am
I created an array
Code: Select all
put "Purpose Data" into ar[1]["purpose" ]
put "Dose Data" into ar[2]["dose" ]
put "Side Effects Data" into ar[3]["side effects" ]
put "Emergency Conditions Data" into ar[4]["Emergency cond" ]
put "Abuse Potential Data" into ar[5]["Abuse Potential" ]
put "Cautions Data" into ar[6]["Cautions" ]
but when I run
Code: Select all
local counter
put 0 into counter
repeat for each key tKey in ar
repeat for each key sKey in ar[tKey]
//put the number of fields of group ar[tKey][sKey] into tCount
end repeat
put counter+1 into counter
put sKey into btnnms[counter]
answer counter & "=" & sKey
end repeat
I get
6=Cautions
1=purpose
2=dose
3=side effects
4=Emergency cond
5=Abuse Potential
Why am I getting the last item in the array first?
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10044
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Wed Jul 12, 2017 1:40 am
Associative arrays have no inherent sense of order. They are name-value pairs, regardless whether the name is numeric or alphanumeric.
If you need to sort keys or other values obtain from an array use the sort command.
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Wed Jul 12, 2017 3:19 am
Your script is correct and works here (both parts in one "MouseUp").
Probably you didn't reset the counter to 0 as above when you got the wrong result?
shiftLock happens