I'm attempting to create a routine to create a delimited ascci text file from 
my table.  I don't want to list every single field because there are so many 
of them.  I would like to be able to just loop through the fields, 
concatenate them into one string and write it.  Assuming I can make this work 
then I will be able to re-use this technique on any of my tables.

If there is a way to reference the fields of a query by index that would be 
best.  Not knowing how to do that I have been attempting to use the list of 
fields provided through ListElement and then to take the field name and 
reference the field that way.  She's a not working.

My code so far ...
<CFLOOP QUERY="GetJobs">
    <CFIF #FileExists(OUTFILE)# is "No">
        <CFSET MyList=#GetJobs.ColumnList#>
        <!--- first line to contain field names--->
        <CFLOOP INDEX="ListElement" List="#MyList#">
            <CFSET TXTOUTPUT = TXTOUTPUT & '#chr(34)##ListElement##chr(34)#, 
'>
        </CFLOOP>   
        <CFFILE ACTION = "WRITE" FILE="#OUTFILE#" OUTPUT="#TXTOUTPUT#">
    <CFELSE>
        <CFLOOP INDEX="ListElement" List="#MyList#">
            <CFSET TXTOUTPUT= TXTOUTPUT &  '#chr(34)#' & 
'#GetJobs.#ListElement##' & '#chr(34)#, '>
        </CFLOOP>       

        <CFFILE ACTION = "APPEND" FILE="#OUTFILE#" OUTPUT="#TXTOUTPUT#">
    </CFIF>
</CFLOOP>

the code #GetJobs.#ListElement## in line 11 obviosuly doesn't work but I have 
yet to figure out a way to substitute a variable as a field name .

Help appreciated (It's a known fact that helping newbies gets you into Heaven)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
------------------------------------------------------------------------------
To unsubscribe, send a message to [EMAIL PROTECTED] with 
'unsubscribe' in the body or visit the list page at www.houseoffusion.com

Reply via email to