>Greetings All:
>
>I am creating a new table from an existing table with the following SQL
>statement:
>
>SELECT UPSINO AS equipnum, EQUIP_TYPE AS apprtype, MANUFACTUR AS mfr, ;
>SERIAL_NO AS serialnum, SUB_NAME as location, 'OILTRN' as rules ;
>FROM CNAME INTO DBF cnamecnv.dbf ORDER BY UPSINO
>
>I am creating a comma-delimited file from the new table, cnamecnv.dbf, with
>the COPY TO command as follows:
>
> COPY TO ALIAS()+".txt" TYPE DELIMITED
>
>However, I need the first record of the TXT file to contain the field names
>of the table used to create the TXT file so it will import into my other
>application correctly.
>
>Any suggestions will be appreciated. If you email me, my address is
>elgin@worldnet.att.net
>
>Thank you.
>
>Elgin.
Hi,
Mail merge wizard would do this. But if you want an exe for any dbf you can do it in many ways, here is one :
function exportascii
parameters cTableName, cFieldList && Comma delimited field list - if you want filtering you could add another parm.
if !used(cTableName)
use (cTableName) in 0
endif
select (cTableName)
copy to TempTxt fields &cFieldList type delimited
handle=fcreate(cTableName+".txt")
handle1=fopen("TempTxt.txt")
=fputs(handle1, CfieldList) && If headers need quotes handle it too
do while !feof(handle1)
=fputs(handle,fgets(handle1,65535),65535)
enddo
=fclose(handle)
=fclose(handle1)
erase TempTxt.txt
Cetin