As a workaround and since the list is small, I have two duplicate sets of values in the array. My question is if anyone has a way or technique to doing some kind of cross referencing that might work so I don't have to include double sets of indexes in my array. The good news is this is just a curiosity for me at the moment... to be efficient. This array will be set once and is static and never changes. It contains static unchanging values and is a way to quickly find the type of info the number or word represents so it can be "written" to an exported file format.
I am using a single function, that I pass either a number or word from the file format and return either a number or word back depending on what is needed.
Below is the array indexed by number values:
(And YES, number 8 is "missing". Don't ask me why. There are only 8 layer types in the file format but 8 is not used for some reason I don't know. The "Sound" layer type was just added in the latest version so that might be a reason.)
Code: Select all
aLayerTypes[1] -- contains "Vector"
aLayerTypes[2] -- contains "Image"
aLayerTypes[3] -- contains "Group"
aLayerTypes[4] -- contains "Bone"
aLayerTypes[5] -- contains "Switch"
aLayerTypes[6] -- contains "Particle"
aLayerTypes[7] -- contains "Note"
aLayerTypes[9] -- contains "Sound"
Code: Select all
aLayerTypes["Vector"] -- 1
aLayerTypes["Image"] -- 2
aLayerTypes["Group"] -- 3
aLayerTypes["Bone"] -- 4
aLayerTypes["Switch"] -- 5
aLayerTypes["Particle"] -- 6
aLayerTypes["Note"] -- 7
aLayerTypes["Sound"] -- 9
Code: Select all
function LayerTypes layerVal
if isNumber(layerVal)
return aLayerTypes[layerVal]
else
put quote & layerVal & quote into layerVal
return aLayerTypes[layerVal]
end if
end LayerTypes