In the <foreach> task the dilim parameter only accepts a single character.
It would be VERY helpful if this took more than a character, so you could
use more complex delimiters to prevent data and delimiters from getting
mixed up.

for example it would be nice to have the following work:

<foreach item="String" in="${bugnotes}" delim="***ROW***"
property="bugnotes.line">
        <echo message="${bugnotes.line}" />
</foreach>

Some other functions that I have added as custom functions follow.  None of
these are polished, but I find the very usefull.

Thanks,

John Cole

a function to do a regex based replace instead of the string based replace.
<script language="C#" prefix="regex">
        <code><![CDATA[
                [Function("replace")]
                public static string RegexReplace(string pSource, string
pSearch, string pReplace) 
                {
                        System.Text.RegularExpressions.Regex re = new
System.Text.RegularExpressions.Regex(pSearch,
System.Text.RegularExpressions.RegexOptions.Singleline);
                        return re.Replace(pSource, pReplace);
                }
        ]]></code>
</script>

a function to load a file into a property
<script language="C#" prefix="file">
        <code><![CDATA[
                [Function("get-file")]
                public static string GetFile( string pFileName ) 
                {
                        string s = "";
                        using (System.IO.StreamReader sr = new
System.IO.StreamReader(pFileName)) 
                        {
                                s = sr.ReadToEnd();
                        }
                        return s;
                }

        ]]></code>
</script>

an odbc query
<script language="C#" prefix="odbc">
        <references>
                        <includes 
name="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" />
        </references>
                
        <code><![CDATA[
                [Function("query")]
                public static string Query(string pConnStr, string pSQL,
string pDelimiter, string pRowDelimiter) 
                {
                        string s = "";
                        string lRowDel = pRowDelimiter.Length == 0 ? "\n" :
pRowDelimiter;  
                        
                        System.Data.Odbc.OdbcConnection c = new
System.Data.Odbc.OdbcConnection(pConnStr);
                        System.Data.Odbc.OdbcCommand cmd = new
System.Data.Odbc.OdbcCommand(pSQL, c);
                        c.Open();
                        System.Data.Odbc.OdbcDataReader r;
                        r = cmd.ExecuteReader();

                        while (r.Read()) 
                        {
                                if (s.Length > 0) s += lRowDel;
                                string line = "";
                                for(int i = 0; i<r.FieldCount; i++)
                                {
                                        if (line.Length > 0) line +=
pDelimiter;
                                        line += r.GetString(i);
                                }
                                if (line.Length > 0) s += line;
                        }
                        r.Close();
                        c.Close();

                        //Console.WriteLine("s length:" +
s.Length.ToString());
                        return s;
                }
        ]]></code>
</script>


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to