Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-02

documentation for file handling, reset, rewrite, errors?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ken G. Brown

I cannot seem to find the good docs for the file handling routines assign, rewrite and reset in the pdf's that came with fpc-2.2.2. Where might the best ones be? I have:
User's Manual.pdf
Units Reference Guide.pdf
Programmer's Manual.pdf
Language Reference Guide.pdf
Free Component Library.pdf
Compiler Switches.pdf
Code Documented.pdf

I would like to find good descriptions of how they work, along with error handling and examples of how to how to best use them.

eg. can an internal memory based file be set to be written and read at the same time? Is the file read position independent of the write position?

If the internal file has been written to the end and the write operation is finished but the file is still open for writing, what needs to be done in order to start reading the file from the beginning?

Are streams available for reading and writing and are they preferable to while not eof (inFi) read(inFi) then write(outFi)?

Are exceptions useful?

Examples?

My goal is to create an internal file then dump it to a system usb printer.

I've found an example of writing to a pipe using assignlst (f,'|/usr/bin/lpr -m'); that seems to sorta work, from here: <http://ubuntuforums.org/showthread.php?t=656110>, 2nd message. Is that a good way to do output to a printer?

Thx again for any pointers.
Ken G. Brown

Michael Van Canneyt
to Ken G. Brown
Ken G. Brown wrote
I cannot seem to find the good docs for the file handling routines assign, rewrite and reset in the pdf's that came with fpc-2.2.2. Where might the best ones be? I have: User's Manual.pdf Units Reference Guide.pdf

Normally, the routines are documented here.

Show quoted text 10 lines
Programmer's Manual.pdf Language Reference Guide.pdf Free Component Library.pdf Compiler Switches.pdf Code Documented.pdf I would like to find good descriptions of how they work, along with error handling and examples of how to how to best use them. eg. can an internal memory based file be set to be written and read at the same time?

Yes.

Is the file read position independent of the write position?

This kind of thing is not explained.

If the internal file has been written to the end and the write operation is finished but the file is still open for writing, what needs to be done in order to start reading the file from the beginning?

With standard file I/O, this is not possible.

Are streams available for reading and writing and are they preferable to while not eof (inFi) read(inFi) then write(outFi)?

They are.

Are exceptions useful?

Yes :-)

Show quoted text 6 lines
Examples? My goal is to create an internal file then dump it to a system usb printer. From your questions, I think you're better off using TMemoryStream and class

based programs. They're more flexible than the standard Pascal file I/O.

I've found an example of writing to a pipe using assignlst (f,'|/usr/bin/lpr -m'); that seems to sorta work, from here: <http://ubuntuforums.org/showthread.php?t=656110>, 2nd message. Is that a good way to do output to a printer?

On linux/unix there is no other reliable way.

Michael.

Ken G. Brown
to Michael Van Canneyt

Thx!

Michael Van Canneyt apparently wrote 8 lines
On Tue, 10 Feb 2009, Ken G. Brown wrote: > I cannot seem to find the good docs for the file handling routines assign, rewrite and reset in the pdf's that came with fpc-2.2.2. Where might the best ones be? > I have: > User's Manual.pdf > Units Reference Guide.pdf Normally, the routines are documented here.

Ah, ok, I was searching for Reset and in the Units Reference Guide it oddly comes up #23 in the list. I didn't happen to catch it that far down. This is what I was looking for.

Ken G. Brown

Show quoted text 5 lines
> Programmer's Manual.pdf > Language Reference Guide.pdf > Free Component Library.pdf > Compiler Switches.pdf > Code Documented.pdf

<snip>

Show quoted text 10 lines
> I've found an example of writing to a pipe using assignlst (f,'|/usr/bin/lpr -m'); that seems to sorta work, > from here: <http://ubuntuforums.org/showthread.php?t=656110>, 2nd message. > Is that a good way to do output to a printer? On linux/unix there is no other reliable way. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal