You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Surtani, Manik" <Ma...@conchango.com> on 2001/09/25 17:00:05 UTC

Javascript to write MKDIR task ...

Hello again,

I have been looking at using javascript with the <script ...> tag to loop
thru tasks, but can't seem to pass values to certain tasks:

E.g., I need to make a series of directories, and I do the following:

   <script language="javascript"> <![CDATA[

      for (i=1; i<=10; i++) {
        md = myProject.createTask("mkdir");
        thisTarget.addTask(md);
        md.setDir("/path/to/dir/dir_" + i);
      }

    ]]> </script>

.. And I get an error about setDir() not taking a String as a parameter.
The ANT API says setDir() takes a File class, but how can I create a File
class out of '"/path/to/dir/dir_" + I' in javascript?

Any help is appreciated.

Thanks in advance.

--
Manik Surtani

Conchango
'Innovative Change in Business'
T 44 (0) 1784 221829
F 44 (0) 1784 470451
E manik.surtani@conchango.com
http://www.conchango.com
 
The information contained in this message is confidential and is intended
for the addressee only. If you have received this message in error, please
notify us as soon as possible. The unauthorised use, disclosure, copying or
alteration of this message is forbidden.


Re: Javascript to write MKDIR task ...

Posted by Diane Holt <ho...@yahoo.com>.
--- "Surtani, Manik" <Ma...@conchango.com> wrote:
> I have been looking at using javascript with the <script ...> tag to
> loop thru tasks, but can't seem to pass values to certain tasks:
> 
> E.g., I need to make a series of directories, and I do the following:
> 
>    <script language="javascript"> <![CDATA[
>       for (i=1; i<=10; i++) {
>         md = myProject.createTask("mkdir");
>         thisTarget.addTask(md);
>         md.setDir("/path/to/dir/dir_" + i);
>       }
>     ]]> </script>
> 
> .. And I get an error about setDir() not taking a String as a parameter.
> The ANT API says setDir() takes a File class, but how can I create a
> File class out of '"/path/to/dir/dir_" + I' in javascript?

  <target name="mkdirs">
    <script language="javascript"> <![CDATA[
      importClass(java.io.File);
      for (i=1; i<=10; i++) {
        md = myProject.createTask("mkdir");
        dir = new File("/path/to/dir/dir_" + i);
        md.setDir(dir);
        md.execute() ;
      }
      ]]>
    </script>
  </target>

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com