Hi Aaronc,

WiX preprocessor does not support recursive variables. You can write a 
preprocessor extension for this purpose.
If you have a rather big common part for different modules (with Porperties, 
CustomActions, CustomTables) you may think about using .wxi files (pass 
parameters to it by defines), or a full WiX-extension (it will help to hide 
some specifics like custom tables definitions).

-Maksim

-----Original Message-----
From: Aaron Klor [mailto:aaron.k...@gmail.com] 
Sent: Friday, April 29, 2011 11:56 PM
To: General discussion for Windows Installer XML toolset.
Subject: [WiX-users] [Wix-users] Recursive preprocessor variables

Hello all,
I have been trying to create a foreach loop to make a few Properties,
CustomActions, and CustomTable rows for each item in the list. I have
previously defined a large number of preprocessor variables (40 in this
case), and i am wanting to reference these by name using the value of the
foreach variable.

Perhaps an example would be helpful. I'm going to leave off my angle
brackets so they aren't killed:

A highly simplified version of my foreach loop:
?foreach INSTANCENUM in "0;1;2;3;4"?
Property Id="property_$(var.INSTANCENUM)"
value="$(var.property_$(var.INSTANCENUM)_value)" /
?endforeach?

in a different part of the source I have defined:
?define property_0_value="examplevalue0"?
?define property_1_value="examplevalue1"?
?define property_2_value="examplevalue2"?
?define property_3_value="examplevalue3"?
?define property_4_value="examplevalue4"?

Expecting the preprocessor to resolve the properties to:
Property Id="property_0" value="$(var.property_0_value)" /
Property Id="property_1" value="$(var.property_1_value)" /
Property Id="property_2" value="$(var.property_2_value)" /
Property Id="property_3" value="$(var.property_3_value)" /
Property Id="property_4" value="$(var.property_4_value)" /

Then eventually output:
Property Id="property_0" value="examplevalue0" /
Property Id="property_1" value="examplevalue1" /
Property Id="property_2" value="examplevalue2" /
Property Id="property_3" value="examplevalue3" /
Property Id="property_4" value="examplevalue4"/


The preprocessor is coming back with the error:
Undefined preprocessor function '$(var.property_$(var.INSTANCENUM)_value)'

It seems to me that this error would be caused by the preprocessor not being
able to handle recursive variables. Is there a way around this? Or can the
preprocessor be extended in order to support this sort of functionality?
Just going through and adding each one of the Properties, CustomActions,
CustomTable rows for each variable is doable, but will make my code increase
in size considerably (on the order of 15-ish lines per iteration) and end up
with a lot of copy/paste.

And for those who wonder the eventual goal for this (as the variable name
implies), i am attempting to make a clever, simple, and reusable (read:
scalable) wixlib to enable large numbers of instances to be available in a
multi-instance environment, and to allow for the simple growth of that
number, as necessary, with minimal code duplication.

This is actually in relation to a previous question on this list that
resulted in Rob Mensching asking whether the addition of the ability to
specify upgrade code on each instance would eliminate this work. The answer
to that is a resounding YES. This preprocessor-ing referenced in my question
would be not necessary if that were possible, with the additional
requirement of being able to save a user-customizable name for each
instance.

Thank you for any help anyone can provide,
Aaron Klor
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network 
management toolset available today.  Delivers lowest initial 
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to