Hi Scot, Thanks a lot for your reply. Yes, I've already known that behavior of "Variable" Task. What I would like to know is the proper coding in Script Task by using Javascript.
I wonder my conding doesn't make sense ? Best Regards, trad-ex >I think the idea here is to use <var> from ant contrib. It definitely >works and allows one to reset properties... > >For instance: > ><project name = "example"> > <taskdef resource = "net/sf/antcontrib/antlib.xml"/> > > <var name = "my-var" value = "foo"/> > <echo message = "my-var = ${my-var}"/> > > <var name = "my-var" value = "bar"/> > <echo message = "my-var = ${my-var}"/> > > <var name = "my-var" value = "alpha"/> > <echo message = "my-var = ${my-var}"/> ></project> > >Will yield: > > [echo] my-var = foo > [echo] my-var = bar > [echo] my-var = alpha > >Above, the variable is being changed... > >trad-ex wrote: >> Hi Steve, >> >> I tried to use "Variables" Task in ant-contrib, but it replicate the >> same result as Dick did. >> My build.xml is: >> >> <?xml version="1.0" ?> >> <project name="build" basedir="." default="test"> >> <taskdef resource="net/sf/antcontrib/antlib.xml"/> >> <target name="test"> >> <script language="javascript"> >> <![CDATA[ >> project = self.getProject(); >> echo = project.createTask("echo"); >> variable = project.createTask("var"); >> variable.setName("theVal"); >> variable.setValue("foo"); >> variable.execute(); >> echo.setMessage(project.getProperty("theVal")); >> echo.perform(); >> echoval.execute(); >> variable.setName("theVal"); >> variable.setValue("bar"); >> variable.execute(); >> echo.setMessage(project.getProperty("theVal")); >> echo.perform(); >> echoval.execute(); >> ]]> >> </script> >> </target> >> <target name="echoval"> >> <echo>${theVal}</echo> >> </target> >> </project> >> >> The Result is: >> >> c:\>ant -v >> Apache Ant version 1.6.2 compiled on July 16 2004 >> Buildfile: build.xml >> Detected Java version: 1.4 in: C:\j2sdk1.4.1_07\jre >> Detected OS: Windows XP >> parsing buildfile C:\build.xml with URI = file:///C:/build.xml >> Project base dir set to: C:\ >> parsing buildfile >> jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/ >> antlib.xml >> with URI = >> jar:file:/C:/apache-ant-1.6.2/lib/ant-contrib.jar!/net/sf/antcontrib/ >> antlib.xml >> Build sequence for target `test' is [test] >> Complete build sequence is [test, echoval, ] >> >> test: >> [echo] foo >> [echo] foo >> [echo] bar >> [echo] foo >> >> BUILD SUCCESSFUL >> Total time: 0 seconds >> c:\> >> >> Why ? >> What's wrong with my description about "Variable" task ? >> Any comments will be very appreciated. >> >> Best Regards, >> trad-ex >> >> >>> Dick, Brian E. wrote: >>> >>>> I have just a day to get this working. These are production machines, so >>>> I can't deploy anything to them. >>>> >>>> I'm using sshexec to remotely ping from a unix host and using rcmd to >>>> remotely ping from a windows host. I redirect the output from these >>>> tasks to a file and then use loadfile with a filterchain to load the >>>> ipaddress into a property. >>>> >>>> This works all fine and dandy except I need to do it in a loop, so that >>>> led me to the script task. But I was having problems getting the >>>> ipaddress set by loadfile back to the script. I didn't want to create >>>> 20x100 properties, but if that's what it takes, so be it. >>>> >>>> >>> In that case, grab the <var> task from ant-contrib, which can be used to >>> erase a property before you reuse it. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> > >-- >Scot P. Floess >27 Lake Royale >Louisburg, NC 27549 > >252-478-8087 (Home) >919-754-4592 (Work) > >Chief Architect JPlate http://sourceforge.net/projects/jplate >Chief Architect JavaPIM http://sourceforge.net/projects/javapim --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]