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"] -- 9Code: 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
 you made it look so easy. The code is so simple. My current solution was similar but had like 3 times the code. You are right about the array. The data set is way too small to actually benefit from a full blown cross dimensional array. Using "repeat with" instead of "repeat for each" shouldn't be a speed hit considering the short list. My concern in the beginning was that there are so MANY layers. If the "repeat with" has to run for each layer it could be very slow. I assume that this array only needs to be generated one time and can be referenced over and over.
 you made it look so easy. The code is so simple. My current solution was similar but had like 3 times the code. You are right about the array. The data set is way too small to actually benefit from a full blown cross dimensional array. Using "repeat with" instead of "repeat for each" shouldn't be a speed hit considering the short list. My concern in the beginning was that there are so MANY layers. If the "repeat with" has to run for each layer it could be very slow. I assume that this array only needs to be generated one time and can be referenced over and over. function that will locate a layer's name or number. I'm sure this could be abstracted more, but I wanted to keep it readable.
 function that will locate a layer's name or number. I'm sure this could be abstracted more, but I wanted to keep it readable.