Array Oddity

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chris9610
Posts: 79
Joined: Fri Mar 20, 2009 4:38 pm

Array Oddity

Post by chris9610 » Wed Aug 12, 2009 8:09 pm

I do not understand this, but this script puts the array keys into the field in this order:

9,8,1,2,3,4,5,6,7

You need a button and a multi line field for this script.

Code: Select all

on mouseUp
   repeat with i = 1 to 9
        repeat with j  = 1 to 9
         put "test data"&&j into ttvar[i][j]
      end repeat
   end repeat
   put keys of ttvar into tkey
   put tkey into fld "fld1"
end mouseUp
Can anyone explain this? I expected them to go in the field in the same order as creation.
Developing with Windows XP & Revolution 4.5

massung
Posts: 93
Joined: Thu Mar 19, 2009 5:34 pm

Post by massung » Wed Aug 12, 2009 8:18 pm

Arrays aren't really arrays (in Rev). They are hash tables. The keys are hashed can can appear - pretty much - in any order.

http://en.wikipedia.org/wiki/Hash_table

Jeff M.

Post Reply