Re: ‘Super Sub’ multidimensional arrays
Sean Cole (Pi)
sean at pidigital.co.uk
Thu Mar 11 18:19:36 EST 2021
Sorry, I just wanted to add...
The keys of tTableA["c:/"] would be:
.FileC
.FileC,Date
.FileC,Kind
.FileC,Size
Folder1
Folder1,Date
Folder1,Kind
Folder1,Size
...
Folder4
Folder4,Date
Folder4,Kind
Folder4,Size
An alternative for "Kind" could be ("Kind_" & tKind) with a value set as
empty of anything else you like. So Folder1 could have a parameter key of
["Folder1","Kind_Folder"] and ".FileC" could have a parameter key of
[".FileC","Kind_HiddenSystem"] maybe. That way you could easily filter the
keys to list only Folders, Hidden Files/Folders or FileTypes.
Sean
On Thu, 11 Mar 2021 at 23:03, Sean Cole (Pi) <sean at pidigital.co.uk> wrote:
> On to Array use for File System Indexing:
>
> Take a simple FS structure:
>
> c:/
> .FileC
> Folder1
> File1.txt
> Folder2
> Size (aka Folder2_1)
> File2.txt
> File2_1.png
> Folder3
> Folder4
> Archive.zip
> File4.doc
>
> 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
> parameter.
>
> Likewise, "Folder3" can readily be stored as ["Folder3","Kind"]="Folder"
> and "Archive.zip" 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.
>
> Sean
>
More information about the use-livecode
mailing list