Arrays: new and old keys, i

Mark Brownell gizmotron at earthlink.net
Sun Sep 14 22:10:47 EDT 2008


-----Original Message-----
>From: David Bovill <david at vaudevillecourt.tv>
>Mark - looking at your script this is NOT doing what we need. It is not
>sorting the keys - it is simply sorting a list, which happens to be inside
>of an array. By that I mean nothing is actually happening to the array - you
>simply extract the contents of an array and sort it.
>

>And even if we could, that doesn't simplify the job of registering the
>sequential order FIFO stye - which we still have to do manually, with all
>the speed loss associated with extra lines of code and using slower repeat
>structures.
>

I hope this works,

You enter the keys into the list while you enter real data stored behind these keys that are the individual containers. It was in my previous post, kind of. I just left out the process.

Let's assume that there is no sort function for keys added or order of entry
set controls.

put chars 4000 to 5000 of zigzag into myArray[4]["4000to5000"]
-- this is the data being stored
-- It received the key "4000to5000"

-- I then created a layer/zone - whatever, (a list) that is appended as I add more and more data with keys added to the layer myArray[4]. Now that I think of it, and keeping with the illusion that I'm always going to keep any dimensional layer's (key registry) in ["keyReg"]. There might be a time when I want to use layer [9].

put "4000to5000," after myArray[4]["keyReg"]["sorted"] -- sort this
put "4000to5000," after myArray[4]["keyReg"]["notSorted"]
put "4000to5000," after myArray[4]["keyReg"]["entryOrder"]
put "4000to5000," after myArray[4]["keyReg"]["globalEntryOrder"]


Later you can sort the list of keys in myArray[4]["keyReg"]["sorted"]

Do you see it yet. "4000to5000" is the key to those 1000 characters that were stored in the dimensional array.

You want at it in the order that it was entered:
put myArray[4][ item 2 of myArray[4]["keyReg"]["entryOrder"] ] into hThis

You want at it in the order that it was sorted:
put myArray[4][ item 1 of myArray[4]["keyReg"]["Sorted"] ] into hThis

You want at it in the order that it was entered anywhere in the array, any layer:
put the number of items in myArray[4]["keyReg"]["globalEntryOrder"] into tNum
put myArray[4][ item tNum of myArray[4]["keyReg"]["globalEntryOrder"] ] into hThis

I don't see the need for the engine to physically move the data if the keys are sorted or custom arranged.

Does that help? 

P.S. Those calls to the array within the calls to the array are untested.


Mark





More information about the use-livecode mailing list