|
#1
|
|||
|
|||
|
How to programmatically set elements of associative array
I want to create/modify items in an associative table. The names of the properties are not known at design time, but are read from a file. I do not see an API such as Table.Add(propertyName, propertyValue) and I have not had much success finding an alternative. Any suggestions about how to accomplish this?
Example: When TU runs, it downloads a file listing my patch definitions. Each patch might include script-specific flags. I have a common patch property set library that will pass this info along to each script. The script will unpack the properties and use them. I was hoping to set the properties in a local associative array to avoid polluting the global namespace. Code:
scriptVariables="CreateRestorePoint=true;FileRoot=files/patch1234";
local MyVariables = {};
while (true) do
local nFoundPos = String.Find(searchString, ";");
if (nFoundPos ~= -1) then
local propertySetting = String.Left(searchString, nFoundPos -1);
local nEqualPos = String.Find(propertySetting, "=");
if (nEqualPos ~= -1) then
local PropertyName = String.Left(propertySetting, nEqualPos -1);
local PropertyValue = String.Right(propertySetting, String.Length(propertySetting) - nEqualPos);
// The following line is syntactically incorrect, but I want the effect myVariables.CreateRestorePoint = true
myVariables...PropertyName = PropertyValue;
end
searchString = String.Right(searchString, String.Length(searchString) - nFoundPos);
else
break;
end
end
Ken Gartner |
|
#2
|
||||
|
||||
|
Hi Ken,
What you should do is use the [] brackets in order to accomplish the addition to the table. So substitute your questionable line below with the following: Code:
MyVariables[PropertyName] = PropertyValue;
__________________
MSI Factory The Next Generation Intelligent Setup Builder |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to put a variabele in a WriteFromString | brianlesker | Setup Factory 7.0 Discussion | 11 | 10-04-2004 06:44 PM |
| INFO: How to Set the Default Application Directory | Support | Setup Factory 6.0 Knowledge Base | 0 | 09-25-2002 01:02 PM |
All times are GMT -6. The time now is 10:36 AM.






Linear Mode

