View Full Version : Referencing standard build variables
03-07-2002, 02:05 PM
OK, I'm an InstallShield newbie, so don't flame me for this semmingly simple question...
I've defined a standard build variable (via Build => Settings => Variables (tab)), now how do I reference it in my script?
I know that predefined system variables like WINDIR or ISPROJECTDIR are referenced like any other variable, but if I define MYDIR (as "c:\mydir"), how do I get at MYDIR? I saw one example where a function was called and a user build variable (myVar) was passed as follows:
(var1, "<myVar>", var3). But this just passes the string "<myVar>", right?
Any help appeciated.
03-08-2002, 08:53 AM
You would think this would be an easy thing to do, however, as far as I have been able to find out, there is no way to get the value of a build variable within your script. You can, however, get the value of a script defined variable (something very similar to a build variable)
There is a ComponentSetTarget (to set its value), but no ComponentGetTarget. So to get a value of a script defined variable, I use a small trick. First I create a small registry set under current user with the script defined I wish to get, then I force it to be evaluated by using CreateRegistrySet, then I get the value using RegDBQueryValueEx. Here is the function I wrote below:
// function takes name of script defined variable
// and returns its value in location
function ComponentGetTarget( scriptvar, location)
NUMBER nvSize, nvType;
nvType = REGDB_STRING;
RegDBGetKeyValueEx("Software\\Installshield\\Script", scriptvar, nvType, szValue, nvSize);
location = szValue;
Then in the Resources pane, go to Registry Sets, and create a registry set named the same as your script variable, and then create a Software\Installshield\Script key with the following value: name: variable name, data: <variable name>,
03-08-2002, 03:12 PM
Thanks tw0001 -
Looks like the user-defined build variables are fairly useless then.... Perhaps something that was never fully implemented by Install Shield.
As for your ComponentGetTarget function -- with a bit of noodling I got it to work great for me. One thing: you say you return the value in location, yet this doesn't seem to happen. And when I looked in Help, it said that you had to use BYREF to return non-numeric values from functions. So, to sidestep the issue - and more importantly, get the thing to work - I simply defined a script-global variable that I set right in the body of the function. It's not elegant...but it works.
Thanks a lot for the help,
03-08-2002, 10:02 PM
Great it worked, I forgot to include the function prototype for that. One thing I figured out is that build variables are used exactly for that, building. That is, the build variables are evaluated at build time (compile time) rather than run time (like script defined vars). So the resulting media contains no reference to the original build variable, only its value. Yes, i agree, not very useful, environment build vars are a little more useful.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.