PDA

View Full Version : Variables in message dialogs now broken?


Tek
03-13-2005, 04:46 PM
Hmm... I could have swore that when I was using the trial version of SF7 (7.0.1.0) before purchasing it last week and getting the latest version (7.0.2.0) that I was able to use variables in dialog messages. I had it working and now it's displaying the variable name rather than its contents.

I use a variable called %ProductNameShort% to display the name of the software being installed in a short form (sort of like saying Windows XP instead of Microsoft Windows XP) in my session variables, but it doesn't seem to use it in dialog messages. This variable is working correctly in other areas of the installer where it is not displayed in a dialog message. The other variable in this code that I use is %OMTEXE% which is just the name of the main executable set in the session variables as well. I handle dozens of software products and the more that I can use session variables, the easier it is for me to copy one SF7 project to another and make as little changes as possible.

Here is my code that I use in my 'On Startup' actions:


-- Check for the existence of a pre v2.1.0 installation and abort if true
EXEExist = File.DoesExist("%AppFolder%\\%OMTEXE%");
EXEVersionInfo = File.GetVersionInfo("%AppFolder%\\%OMTEXE%");
EXEVersion = EXEVersionInfo.FileVersion;
if (EXEExist) and (EXEVersion < "2.1.0.24") then
result = Dialog.Message("Older Version Detected", "Setup has detected that you currently have an older version of ".."%ProductNameShort%".." installed prior to version 2.1.0.\nYou must first uninstall any existing ".."%ProductNameShort%".." software before installing this version.\n\nYou can uninstall previous versions from the Control Panel under Add/Remove Programs.\n\nSetup will now close.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);
Application.Exit(0);
end


Am I missing something? Did something change?

Confused,

Tek

csd214
03-13-2005, 11:27 PM
My wife says, "Milk is for calfs". I should say, "Session varaiables are for screens. The strong action engine needs ordinary variables."

To use a session variable in an action, you have to expand it.
EXEExist = File.DoesExist(SessionVar.Expand("%AppFolder%\\%OMTEXE%"));

My personal habit:
If I use a session variable several times in the code, I expand it once and store the value in an ordinary variable:

sProductNameShort = SessionVar.Expand("%ProductNameShort%");

Then I can reuse the variable without the expanding:

Dialog.Message("Older Version Detected", "Setup has detected that you currently have an older version of "..
sProductNameShort.." installed prior to version 2.1.0.\nYou must first uninstall any existing "..
sProductNameShort.." software before installing this version.\r\n"..
"\r\nYou can uninstall previous versions from the Control Panel under Add/Remove Programs.\r\n"..
"\r\nSetup will now close.", MB_OK, MB_ICONSTOP, MB_DEFBUTTON1);

This demonstrates another habit of mine; I split long code lines with the string concatenation operator. I hate the long command lines!

Well, I still have my membership in "The Confused Designers Foundation". From time to time, I visit their meetings, but my overall view is:

To work with the Lua engine in the I.R. products is like a voyage of discovery. You regularly strike a treasury. :yes

Tek
03-14-2005, 03:09 AM
Well thank you!

I don't know what I did but I understand SF7 a little bit more now.

"SessionVar.Expand" always confused me somehow.

I've cleaned things up now.

Thanks for the tips.