Re: ‘Super Sub’ multidimensional arrays

Sean Cole (Pi) sean at
Thu Mar 11 18:03:36 EST 2021

On to Array use for File System Indexing:

Take a simple FS structure:

        Size  (aka Folder2_1)

Say we want to store in our indexing array the sizes, creation dates and
kind of every file, folder and volume.

If we ploughed in without thinking to much about it we might put File1.txt
in as:  'put tValue into
tTableA["c:/"]["Folder1"]["File1.txt"][tParameter]'    with tParameter
being "Size", "Date" or "Kind". That seems ok.
But what about, then, size of Folder2?   'put tFldrSize into
tTableA["c:/"]["Folder2"]["Size"]' .  What happens to the contents of a
folder 'named' "Size" once the parameter 'Size' gets written to in the
array? It writes over all of it.

So, maybe, a 'better', more manageable approach might be to have parameters
stored thusly:  'put tFldrSize into tTableA["c:/"]["Folder2","Size"]'
Then the File named "File2.txt" could be stored
as tTableA["c:/"]["Folder2"]["Size"]["File2.txt"] without fear
that ["c:/"]["Folder2"]["Size"] might be overwritten accidentally by a

Likewise, "Folder3" can readily be stored as ["Folder3","Kind"]="Folder"
and "" could have a kind set as "Zip", and could then be scanned
even later for its contents with them being added to the sub-structure of
the array.

So, using {curly brackets} to denote optional parameters, the syntax for
this array could be thought of as:
        put tValue into tMyArrayA [tItemName {, tParameterName} ]
        put tValue into tMyArrayA [tItemName ] { [tItemName] ... [tItemName
{, tParameterName} ] }
        put tFolderA into tMyArrayA [tItemName ] { ... [tItemName ] }

I hope that all makes sense.


More information about the use-livecode mailing list