array info request

Dennis Brown see3d at writeme.com
Mon Jul 25 19:58:57 EDT 2005


Thomas,

I find arrays are very useful when you want to get random as opposed  
to sequential access to data.  Most of my arrays are generated by  
using the split command.  I read a file in, then split it by return  
to get quick random access to the lines, then I get a line and split  
it by comma to get quick access to an item.  I also generate arrays  
on the fly to hold info when I need to calculate the name of the info  
--this is surprisingly useful.

Custom properties are ways of attaching arrays to an object so that  
it is persistent.  It is a little harder to play with the creation of  
arrays, and the keys are a bit harder to get and change, but not very  
bad.

One way I use arrays is to hold the true/false answer to pre- 
calculated decisions.  Say I have a complex UI and a program that  
iterates through a lot of data in different ways depending on the  
complex relationships selected in the UI.  I pre-calculate all the UI  
decisions that I can for the IF THENS that are inside the loops.   
That way all the loops run faster.  Each decision point is at a index  
key something like "1a3".

You can actually do a lot of "logic" by creating arrays that hold the  
keys to other arrays.  Once you get you head around them, you will  
wonder how you ever programmed anything without them.

A friend of mine used arrays in the APL language 30 years ago to  
write a program called HexaPawn.  It is a 6x6 Chess board with just 6  
pawns on each side.  You play against the computer.  He wrote the  
game logic, and made it self learning in 6 terse lines.  He  
unfortunately needed another 6 lines for the UI code to type out the  
chess board after each move and get the next move.  Of course the Rev  
arrays are very crude compared to APL, but still extremely useful.

Dennis


On Jul 25, 2005, at 6:28 PM, Thomas McGrath III wrote:

> Pardon me butting in here but I have a question:
> Then what is the best use of arrays? What can/should they be used for?
>
> I understand the use and need for a custom property and the need  
> for databases but what about these here arrays???
>
>
> Thank you
>
> Tom
> On Jul 25, 2005, at 6:13 PM, Mark Wieder wrote:
>
>
>> You're bordering *very* close to where you'd be better off using a
>> database than trying to store things in arrays.
>>
>> Keep in mind that arrays are temporary. If you need persistent  
>> storage
>> and you're not using a database then you'll need to store the arrays
>> in custom variables in a substack:
>>
>> set the books of mySubStack to tBooks
>>
>> -- 
>> -Mark Wieder
>>
>>
>
>
> Macintosh PowerBook G-4 OSX 10.3.9, OS 9.2.2, 1.25 GHz, 512MB RAM,  
> Rev 2.6
>
>
> Advanced Media Group
> Eagle Works Art & Sculpture
> Semantic Compaction Systems
> Prentke Romich Company
> Prentke Romich International
> SCIconics, LLC
> Artist
> Thomas J McGrath III
> 3mcgrath at adelphia.net
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list