get the keys of an array

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

get the keys of an array

Post by jmburnod » Fri Apr 05, 2013 6:38 pm

Hi All,
I have to choose between two methods to classify a list of png files like this:

Code: Select all

size,image1.png,image2.png,image…
Methode 1
Use the size of file as number of the currentline in a loop

Methode 2
Use the size of file as name of array key in a loop

Methode 2 is faster than Methode 1 but i read "keys of tarray" is desktop only

Is there a way to get the keys of an array on IOS ?

Best regards
Jean-Marc
https://alternatic.ch

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: get the keys of an array

Post by sturgis » Fri Apr 05, 2013 6:50 pm

Use element instead. SHould work.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get the keys of an array

Post by jmburnod » Sat Apr 06, 2013 9:02 am

Hi Sturgis,

Thanks for your reply

Code: Select all

 put the keys of gDataA into tK
work fine

Code: Select all

put the elements of gDataA into tK
return an error (Expression: bad factor)
Kind regards
Jean-Marc
https://alternatic.ch

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: get the keys of an array

Post by sturgis » Sat Apr 06, 2013 2:15 pm

Hmm. DOH, I misread it. It works with the values not the keys. DOH.

I'm thinking, surely the array stuff has been updated to include IOS and android. Have you tested getting the keys on a device? The dictionary has been known to be wrong once in a while.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get the keys of an array

Post by jmburnod » Tue Apr 09, 2013 3:39 pm

Thank for the doubt about dictionary :D
The dictionary has been known to be wrong once in a while.
You're right. I tested on my iPad

Code: Select all

get the keys of myArray 
work fine
Does someone can confirm it work with androïd ?
Best
Jean-Marc
https://alternatic.ch

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: get the keys of an array

Post by sturgis » Tue Apr 09, 2013 4:18 pm

Yep, android is fine too.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get the keys of an array

Post by jmburnod » Tue Apr 09, 2013 4:25 pm

Great !
I put a comment in the Dictionary User notes
https://alternatic.ch

Post Reply