Board index » delphi » Rewrite Statement help

Rewrite Statement help

This is a multi-part message in MIME format.

------=_NextPart_000_01BCD50A.5C4EF940
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Could anyone tell me how to:

Make a record be more than the normal 128 bytes.

I made a program that outputs everything into an html file, but not
everything fits because it is over 128 bytes

I know it goes something like this rewrite(varible, etc...)

Please help

-Toly
------=_NextPart_000_01BCD50A.5C4EF940
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<html><head></head><BODY bgcolor=3D"#FFFFFF"><p><font size=3D2 =
color=3D"#000000" face=3D"Arial">Could anyone tell me how =
to:<br><br>Make a record be more than the normal 128 bytes.<br><br>I =
made a program that outputs everything into an html file, but not =
everything fits because it is over 128 bytes<br><br>I know it goes =
something like this rewrite(varible, etc...)<br><br>Please =
help<br><br>-Toly</p>
</font></body></html>
------=_NextPart_000_01BCD50A.5C4EF940--

 

Re:Rewrite Statement help


Quote
> Could anyone tell me how to:
> Make a record be more than the normal 128 bytes.
> I made a program that outputs everything into an html file, but not
> everything fits because it is over 128 bytes

> I know it goes something like this rewrite(varible, etc...)

   No, and you're confused about some things here.  
   In Pascal, you can define "records" of virtually _any_ size (in TP/BP,
you're limited to 64K bytes), and you can write file data records of
those defined types.  However, that doesn't seem really pertinent to your
problem - but it's something you should understand.
   I suspect your difficulty is that you don't understand (1) that you
can work with TP/BP strings of up to 255 bytes, (2) writeln will deliver
_whatever_ data you send to it to a Text file, and (3) the default 128
byte buffer for TP/BP files isn't the problem here: you're probably not
closing the file (and is why you get only 128 bytes written to the file).
   So, you must always Close any file you're writing to (to flush data
remaining in the internal buffer - something that's _not_ done for you by
TP/BP RTL).
   Now, if _performance_ of writing Text file output file is an issue for
you (and I somewhat doubt it is, for an HTML application), you can
override the default 128 byte file buffer by using SetTextBuf (after the
Assign), and you can thereby use your own internal buffer...up to 64K in
size).  Note that this isn't a complete answer to your problem, since a
larger buffer which _isn't_closed_ will make your problem even worse: you
may not get _any_ data actually written to the file (if you don't Close
it)!  
   Bottom line: you can improve performance of file I/o by using
SetTextBuf and your own data buffer; and you _MUST_ Close any file you've
opened and written data to.

Re:Rewrite Statement help


Quote
Toly wrote:
> Could anyone tell me how to:

> Make a record be more than the normal 128 bytes.

> I made a program that outputs everything into an html file, but not
> everything fits because it is over 128 bytes

> I know it goes something like this rewrite(varible, etc...)

> Please help

Post source demonstrating your problem, please.  Rewrite() just opens a
file for writing.  Writing to the file requires write() (typed and text
files), writeln() (text files), or blockwrite (untyped files).

As you ask your question, I'm not sure it's answerable.

Quote
> -Toly

--
Scott Earnest        | We now return you to our regularly |
set...@ix.netcom.com | scheduled chaos and mayhem. . . .  |

Re:Rewrite Statement help


In article <01bcd52b$e3609940$ca807...@Toly.netaxis.com>, t...@netaxis.com
says...

Quote
>Could anyone tell me how to:
>Make a record be more than the normal 128 bytes.
>I made a program that outputs everything into an html file, but not
>everything fits because it is over 128 bytes
>I know it goes something like this rewrite(varible, etc...)

You can specify the record size with Rewrite(yourfile,recsize);
But I think it's not the best way to handle text files. Why don't you use the
standard text file I/O routines? Example:

var HTML: text;
begin
  assign(HTML,'test.htm');
  rewrite(HTML);
  writeln(HTML,'<HTML><H1>This is a test</H1></HTML>');
end.

Write() and Writeln() can handle lines up to 255 chars (or longer in two or
more steps). You can try using PChar variables, too...

BandiT

Re:Rewrite Statement help


In article <MPG.ea8362f83109fb7989...@news.primenet.com>,
  mrc...@primenet.com (Mike Copeland) wrote:

Quote

> > Could anyone tell me how to:
> > Make a record be more than the normal 128 bytes.
> > I made a program that outputs everything into an html file, but not
> > everything fits because it is over 128 bytes

> > I know it goes something like this rewrite(varible, etc...)
>    I suspect your difficulty is that you don't understand (1) that you
> can work with TP/BP strings of up to 255 bytes, (2) writeln will deliver
> _whatever_ data you send to it to a Text file, and (3) the default 128
> byte buffer for TP/BP files isn't the problem here: you're probably not
> closing the file (and is why you get only 128 bytes written to the file).
>    So, you must always Close any file you're writing to (to flush data
> remaining in the internal buffer - something that's _not_ done for you by
> TP/BP RTL).

You could use my TTxtFile object (found at
http://www.geocities.com/Sunsetstrip/Stage/7431/delphi_txtfile.html ) and
then all you will have to do is just create an object instance, write to
it and then free it (Free will automatically close the file if it wasn't
closed already). Or you could derive TTxtFile from TComponent, not from
TObject, and thus get the possibility to drop it on the form (and then it
should be destroyed and therefore closed any time you close the form)
Also take a look at my Source->HTML Generator
(http://www.geocities.com/Sunsetstrip/Stage/7431/delphi_generator.html)
which uses TTxtFile.

HTH

Syarzhuk Kazachehnka

P.S. If you use my code all you have to do is notify me by email. If you
change it you have to send me your changes

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

Other Threads