Alternative way of appending content to a file

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Alternative way of appending content to a file

#1 Post by Andy Edward »

Hi,

I'm generating an HTML file (for reports) which I don't really know how big it will be.

Currently I'm using MEMOWRITE like so, which will write to the file for every record

Code: Select all

1st way
***********
DO WHILE !EOF()
     xCONTENT = "Some content that is based on the current record"
     EXPTEXT=MEMOREAD(xHTMLFILE)+XCONTENT   && 20160302
     MEMOWRITE(xHTMLFILE,EXPTEXT)            && 20160302
SKIP 
ENDDO
I understand that this way is non optimal as when the XHTMLFILE becomes too big (10MB-100MB), then the whole process of reading (MEMOREAD) and writing back will degrade speed wise.

I can always do something like this

Code: Select all

2nd way
***********
DO WHILE !EOF()
     xCONTENT += "Some content that is based on the current record"
SKIP 
ENDDO

EXPTEXT=MEMOREAD(xHTMLFILE)+XCONTENT   && 20160302
MEMOWRITE(xHTMLFILE,EXPTEXT)            && 20160302
but I don't know how much data xCONTENT variable will be able to store.

So my questions are:
For the 1st way, is there a function in xBase that will append the file instead of needing to read the file, append, and then write it back?

For the 2nd way, how much data can a variable hold? as the data size is unknown and might grow larger along the years. And I'm talking about 10MB-100MB

Any help is appreciated.

Regards,

Andy

Wolfgang Ciriack
Posts: 479
Joined: Wed Jan 27, 2010 10:25 pm
Location: Berlin Germany

Re: Alternative way of appending content to a file

#2 Post by Wolfgang Ciriack »

Look at the function StrFile(), f.e.

Code: Select all

strfile(EXPTEXT,xHTMLFILE,.T.)
appends to the existing file xHTMLFile.
_______________________
Best Regards
Wolfgang

Andy Edward
Posts: 103
Joined: Fri Sep 17, 2010 2:58 am

Re: Alternative way of appending content to a file

#3 Post by Andy Edward »

Wolfgang Ciriack wrote:Look at the function StrFile(), f.e.

Code: Select all

strfile(EXPTEXT,xHTMLFILE,.T.)
appends to the existing file xHTMLFile.
Thank you very much!

Regards,

Andy

Post Reply