Hi Jaroslaw, Gert,

Thanks for your help. I must admit, I don't quite understand why the if
evaluation is not delayed in the same way the property value is. 

Anyway, I've tried the suggestion below. My test has about 11 levels of
if, and although it doesn't look nice, it works well. I didn't realise
that the if could be used in this way.

Thanks again,
Nick.

-----Original Message-----
From: Jaroslaw Kowalski [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 16 September 2004 5:00 PM
To: Gert Driesen
Cc: Nick Zigomanis; [EMAIL PROTECTED]
Subject: Re: [Nant-users] dynamic properties and functions

It should be possible to use the if() operator:

<property name="idl.out.dir" value="${
if(string::contains(this.idl, 'Source\Data'),
    bin.root + '\Data',
    if (string::contains(this.idl, 'Source\Common'),
        bin.root + '\Common',
        ''))
}" dynamic="true" />

The semantics of if(a,b,c) is: "if a=True then b else c" which is 
exactly what "a ? b : c" operator from C/C++/C#.

Gert, what do you think of extending it to (backward compatible):

    if (condition1,result1,condition2,result2, ..., conditionN,resultN, 
otherwise)

Other ideas (language constructs):

    ${if a then b else c}
    ${choose
        when condition1 then result1
        when condition2 then result2
        ...
        when conditionN then resultN
        otherwise resultOtherwise}
  
Jarek

Gert Driesen wrote:

> Nick,
>
> The "if" condition is evaluated, not the value of the property.
>
> Gert
>
> ----- Original Message ----- From: "Nick Zigomanis" 
> <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 16, 2004 7:06 AM
> Subject: [Nant-users] dynamic properties and functions
>
>
> Hi all,
>
>
>
> I'm trying to set dynamic properties in my build file as shown below:
>
>
>
> <property name="idl.out.dir" value="${bin.root}\Common" dynamic="true"
> if="${string::contains(this.idl, 'Source\Common'}" />
>
> <property name="idl.out.dir" value="${bin.root}\Data" dynamic="true"
> if="${string::contains(this.idl, 'Source\Data'}" />
>
>
>
> Essentially, all idl's under a specific source hierarchy (which is
> tested by the string::contains function) are compiled to a single bin
> directory.
>
>
>
> However, in doing the above, I get the following error when running
the
> build script:
>
>
>
> Property evaluation failed.
>
> Expression: ${string::contains(this.idl, 'Source\Common'}
>
>                                                 ^^^^^^^^
>
>                         Property 'this.idl' has not been set.
>
>
>
> It seems that even though a dynamic property is specified, the
function
> tries to do an evaluation even before the property is being used,
i.e.,
> in this case, it is not dynamic.
>
>
>
> Can anyone confirm this, or point out any problems in my approach, or
> possibly, a better way to do this.





-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to