Indigo Rose Software

Go Back   Indigo Rose Software Forums > Old Versions > TrueUpdate 2.0

 
 
Thread Tools Display Modes
  #1  
Old 04-18-2005
Ken Gartner Ken Gartner is offline
Forum Member
 
Join Date: Feb 2005
Posts: 14
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
Thanks for your suggestions.

Ken Gartner
  #2  
Old 04-18-2005
Mark's Avatar
Mark Mark is offline
Indigo Rose Staff Member
 
Join Date: Jun 2000
Location: Indigo Rose Software
Posts: 1,773
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;
This will basically add an entry into the MyVariables table at position PropertyName, with value ProperyValue.
__________________
MSI Factory The Next Generation Intelligent Setup Builder
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


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.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software