Page 1 of 1

Create Text File

Posted: Fri Apr 11, 2008 12:45 am
by Colin Haig
Hi All

I have to create a text file to send data to a bank - I created a database
with one field - I build each line in the databases and then use copy to
SDF with no delimiters but when the file is created it has an end of line
marker - when the file is imported to the bank it fails because of the end of line marker - can anyone suggest another way to do this.

Regards

Colin

Posted: Fri Apr 11, 2008 1:09 am
by yury
hello,

you can create txt files using the class TTxtfile:

Code: Select all

cFile = 'MyOrder.txt'


oFile = TTxtFile():New( cFile )


select mBD
go top


while .not.eof()
   cLine = ''
   
    for ii=1 to fcount()
        cLine+=fieldget(ii)
    next
  
   oFile:Add( cLine )
   skip +1
enddo


oFile:Close()


return 
regards

Re: Create Text File

Posted: Fri Apr 11, 2008 1:13 am
by mmercado
Colin Haig wrote:I have to create a text file to send data to a bank - I created a database
with one field - I build each line in the databases and then use copy to
SDF with no delimiters but when the file is created it has an end of line
marker - when the file is imported to the bank it fails because of the end of line marker - can anyone suggest another way to do this.
Hi Colin:

The same way you fill the record field, you may fill a cLine character variable, then add it to a cText next way:

Code: Select all

cText := ""

For nI := 1 To nTotalLines
   cLine := cYourTextLine
   cText += cLine + CRLF
Next

MemoWrit( "MyText.txt", cText )
I hope have been helpfull

Regards

Manuel Mercado

Create Text File

Posted: Fri Apr 11, 2008 2:38 am
by Colin Haig
Thanks Yuri and Manual for your quick replies - I used the TTxtFile Class
and everything worked fine.

Regards

Colin