Slight correction (forgot first parameter for GetVariableValue). Corrected
inline.

-----Original Message-----
From: Blair [mailto:os...@live.com] 
Sent: Tuesday, February 16, 2010 10:36 PM
To: 'General discussion for Windows Installer XML toolset.'
Subject: RE: [WiX-users] Is it possible to dynamically access a ?define
variable in WiX

You are exactly on the right track. Your extension will implement a prefix
of "Blah", will respond to a function named "GetValue", and that function
will return the value from Core.GetVariableValue("var", args[0]);

Before your extension is called, "$(lang)_cost" will be replaced in the
preprocessor by each successive value of "chs_cost", "cht_cost", etc. Your
extension calls into the PreprocessorCore class asking for the value of
those variables and those become the return value from your function.

So, your preprocessor class would contain (this is just part of your
implementation, treat as sample code):

    private string[] prefixes = { "Blah" };
    public override string[] Prefixes
    {
        get { return prefixes; }
    }

    public override string EvaluateFunction(string prefix, string function,
string[] args)
    {
        // Perform validation, etc
        switch (prefix)
        {
        case "Blah":
            switch (function)
            {
            case "GetValue":
                // you may consider checking for missing values before
returning here
                return core.GetVariableValue(null, "var", args[0]);
            }
        }
        // you may consider different error handling here.
        return null;
    }

The rest of the needed code is broilerplate WiX Extension code which is
documented elsewhere (blogs, this list, the chm).

-----Original Message-----
From: jnewton [mailto:jonathan.new...@ni.com] 
Sent: Tuesday, February 16, 2010 5:53 PM
To: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Is it possible to dynamically access a ?define
variable in WiX


Maybe I don't understand the GetVariableValue method, but it seems to need a
prefix and a variable name. What if I want the normal variables with the
prefix of "var" like $(var.myVariableName)? I didn't see any options to get
the variables you defined in the wix source. Like I was thinking of
something like:

<?define cost = 55 />
<Property Id="TEST" Value="$(Blah.GetValue(cost))" />

In this case, the prefix is var. 

I am envisioning something like:
<?define chs_cost = 55" />
<?foreach lang in chs;cht..?>
<Property Id="TEST" Value="$(Blah.GetValue($(lang)_cost))" /> 
<?endforeach>

This would end up pass values like chs_cost and cht_cost to the extension.
Then I would like to say GetVariableValue("var", "chs_cost") and it would
give me a value of 55.

Make sense?

I'm just not seeing how I would implement this. Am I on the write track? If
I want to access already defined variables that have a prefix of var, what
do I need to call?

Thanks
-- 
View this message in context:
http://n2.nabble.com/Is-it-possible-to-dynamically-access-a-define-variable-
in-WiX-tp4582645p4583797.html
Sent from the wix-users mailing list archive at Nabble.com.

----------------------------------------------------------------------------
--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users




------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to