This content has been marked as final. Show 3 replies
While it's possible to do this (create arbitrarily named variables on the fly) using director's "do" command, I would advise against it. It almost always leads to poorly structured code when better options exist.
Might I suggest creating a property list to contain your 'created lists'. Perhaps if you describe more clearly what it is you want to end up with, someone could provide some suggestion as to how to achieve it.
As far as I can see, your unique identifying field is 'cat' (presumably 'catalog number?'). If this is the case, perhaps you should create a property list called products, within which you can place each new property for each record:
products = [:]
...then, within the loop through each record, build a new property list:
thisRecord = [:]
thisRecord[#cat] = recordData
thisRecord[#bldgName] = recordData
thisRecord[#bldgAddress] = recordData
thisRecord[#bldgArea] = recordData
thisRecord[#bldgUses] = recordData
thisRecord[#bldgNumFloors] = recordData
thisRecord[#bldgHeight] = recordData
thisRecord[#bldgYear] = recordData
thisRecord[#bldgExt] = recordData
thisRecord[#bldgUBC] = recordData
...and add it to the 'products' proplist, using its own 'cat' value (presuming that is the unique record ID) as the property name:
products[thisRecord.cat] = thisRecord
You should end up with a property list called 'products', from which you can retrieve any product, by referring to its 'cat':
put products["2264"] (assuming there was a record with "2264" as its 'cat')
This method is using strings for the property names in the 'products' proplist, because as I recall your 'cat' values are 4 digit numbers.
Hope this helps!
That solution sounds good I am going to explore that. I don't have categories, I just took this code form someone in this forum and have yet to change the variable names to more appropriate things.
I have buildings with building numbers. What would work for me is to have one list that contains a property list for each building. The property list would then contain:
and so forth.
Your suggestion worked very well, thank you so much. It is exactly what I needed.