Load Variables from IniFile

In our projects we have been using the Load Variable from inifile as one of our main source to populate in to delcared variables, which in most cases do not have a default value

This works fine and easy to change the inifile and load, but we are now getting in wher people do not want to change for example a release variable that is read in but they want to pass the variable within the command line into the project with the /v option. 

If they do this when it hits the load it will change it back to what the inifile has.  So since these varaibles are not defined, I use the If Variable Defined option and then I can peform an load variables from inifile for that variable and this seems to work, but is there a way to modifiy the Load Variable from ini file and uncheck that variable instead so then what remains in a one step process is read the variables that are not passed?

 

Hi Dennis,

The short answer to this is No, the solution you have is probably the ideal solution.

The long answer is that Yes, you can do it, by writing script to address the Action.Variables property, which is a list of the checked variables in the action.

Here is some sample JScript to do this. In order to return the result to the original setting, you will need to define a new FB Project variable called TempVariablesList. If you don't need to keep these settings (ie you're running under FBCMD, so the project will never be saved) then you can remove this variable, and comment out the two lines in my example which refer to it.

Put this into the BeforeAction script event for the Load Variables action:

TempVariablesList = Action.Variables.Text;
for(var j = 0; j < Action.Variables.Count; j++)
{
if(eval("FBVariables." + Action.Variables[j]) != "")
{
Action.Variables.Strings(j) = "";
}
}


... and put this into the AfterAction script event:


Action.Variables.Text = TempVariablesList;


... that should do it. Like I said, though, this is a hack. If there is some way you can restructure your build process to avoid this, I would recommend doing that.

Regards,

Angus

 

Edit: Fixed a minor error

I am attaching one of my projects you will see what I have done inside the  Action Group - Variable Load Application Specific

This works if the pass in a parameter as well as if they do not it will read the inifile and either use its parameter or read a common area.  This works well with the /v option. 

Further down in the projects main location you will see

If [%OutputDirectory%] <> [EMPTY]  and  [%BinaryVersion%] <> [EMPTY]  and  [%BinaryLocation%] <> [EMPTY]

I do have a development build that is launched via this outputs that will build our packages.  This is how I can have them pass in via a development branch.  I am now able to pass in a release build parameter, use the current inifile parameter or build via development build.  My next step will be to change the property set via external settings during our perforce branch to match the next release number and then compare to what is passed to build an offical release since we addmany other items for the release!

Dennis

 

Test.fbz5 (47.085 KB)

Hi Dennis,

That sounds like a great solution.

Regards,

Angus

PS I noticed a minor error in the script I gave you last week, it’s been corrected but it doesn’t sound like you need it any more.

Angus,

Please post the change since there might be others that would love to use your script. as well as I might test it to see if it is faster then what I am doing!

 

Dennis

Hi Dennis,

I edited the post, so the script is now correct. Sorry, I should have made that clearer. I had the assignment statement in the AfterAction event written backwards (in my defence, I wrote the script on the day after I got back into Canberra from Barcelona, so maybe my brain was still on Spain time ;).)

Regards,

Angus

Thanks for the response, I understand how things can be coded when you want it a different way!