macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

downloaded the UDF exsamples. i need help in testing it. thanks

Subject: downloaded the UDF exsamples. i need help in testing it. thanks
From: "silviasalsa"
Date: Thu, 23 Aug 2007 16:12:48 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
hello i have this UDF and i wanted to test it in my development environment.    
 
 can you help me

 i have put the table as the data source in admin.  
 and have a table ready that has the same field names.

 what do i do now?


 Parameters
 Name   Description     Required
 query  The query to format.    Yes
 qualifer       A string to qualify the data with.      No
 columns        The columns ot use. Defaults to all columns.    No
 Return Values
 A CSV formatted string. 
 Example
 <cfscript>
 mytestquery = QueryNew('FirstName,LastName,Title');
 QueryAddRow(mytestquery, 3);
 QuerySetCell(mytestquery, 'FirstName', 'Steve', 1);
 QuerySetCell(mytestquery, 'LastName', 'Drucker', 1);
 QuerySetCell(mytestquery, 'Title', 'CEO', 1);
 QuerySetCell(mytestquery, 'FirstName', 'Dave', 2);
 QuerySetCell(mytestquery, 'LastName', 'Watts', 2);
 QuerySetCell(mytestquery, 'Title', 'CTO', 2);
 QuerySetCell(mytestquery, 'FirstName', 'Dave', 3);
 QuerySetCell(mytestquery, 'LastName', 'Gallerizzo', 3);
 QuerySetCell(mytestquery, 'Title', 'VP', 3);
 </cfscript> 
 <cfoutput>
 <pre>
 #CSVFormat(mytestquery, "'")#
 </pre>
 </cfoutput> 
 <!-----------------------------------------à

 <cfscript>
 /**
  * CSVFormat accepts the name of an existing query and converts it to csv 
format.
  * Updated version of UDF orig. written by Simon Horwith
  * 
  * @param query         The query to format. 
  * @param qualifer      A string to qualify the data with. 
  * @param columns       The columns ot use. Defaults to all columns. 
  * @return A CSV formatted string. 
  * @author Jeff Howden ([email protected]) 
  * @version 2, December 3, 2001 
  */
 function CSVFormat(query)
 {
   var returnValue = ArrayNew(1);
   var rowValue = '';
   var columns = query.columnlist;
   var qualifier = '';
   var i = 1;
   var j = 1;
   if(ArrayLen(Arguments) GTE 2) qualifier = Arguments[2];
   if(ArrayLen(Arguments) GTE 3 AND Len(Arguments[3])) columns = Arguments[3];
   returnValue[1] = ListQualify(columns, qualifier);
   ArrayResize(returnValue, query.recordcount + 1);
   columns = ListToArray(columns);
   for(i = 1; i LTE query.recordcount; i = i + 1)
   {
     rowValue = ArrayNew(1);
     ArrayResize(rowValue, ArrayLen(columns));
     for(j = 1; j LTE ArrayLen(columns); j = j + 1)
       rowValue[j] = qualifier & query[columns[j]][i] & qualifier;
     returnValue[i + 1] = ArrayToList(rowValue);
   }            
   returnValue = ArrayToList(returnValue, Chr(13));
   return returnValue;
 }
 </cfscript>


<Prev in Thread] Current Thread [Next in Thread>
  • downloaded the UDF exsamples. i need help in testing it. thanks, silviasalsa <=