Thanks Elan:
Your discussion is very helpful. As to your
question:
>I haven't been following this thread, so I don't know why you are using
>ports. Generally speaking, it is often more convenient to use higher
As to the above, I want re-usable code that will allow me
to easily write to a file OR to standard output. My approach
is to set up a value that could point EITHER to a file or
to standard output.
EX: in C:
FILE *f;
if(write_to_file)
f = fopen("test.txt","w")
else
f = stdout;
fprintf(f,"line one");
That in
part is my choice of using ports. Part of that is circumstance,
as well, perhaps the upper level functions would be better,
given this need. I would welcome your advice.
As well, I come from the c/c++/assembler background,
I try to think in terms of minimizing machine overhead.
I do primarily CGI programming, and like to use
the same code to do either web content or send that
web content to file. Either for testing purposes or in
case a client wants me to enable him/her to build or update
a page on the machine end.
Keep up the good work Elan, you are always helpful.
tim
At 01:19 PM 4/2/00 -0700, you wrote:
>Hi t,
>
>A file! type is a filename with a leading % character. Example: %myfile.r
>%/c/mydir/. A file! may be any type of file, including a directory.
>
>A port! datatype is a low-level i/o abstraction that REBOL uses to
>serialize different types of i/o channels, such as files (here we are not
>talking about the filename, but access to the file's contents), and socket
>i/o.
>
>The access to ports is typically controlled by protocols that define how
>information is read and written to a port, and also commonly implement some
>convenient navigation functions for the port's datastream, such as first,
>next, insert, pick, etc. These functions work in a sensible way on a port!
>datatype. They enable you to treat ports as though they were series values
>(i.e. blocks, paths, hashes ...) to a degree, hence the term serialize is
>used to describe this type of access to i/o channels.
>
>There are some limitations, since not all ports lend themselves to being
>treated as a series effectively with respect to all series! functions.
>
level
>functions when dealing with files, then accessing them as ports. read,
>write, read/lines, write/append write/lines, write/append/lines, save,
>load, come to mind. All of these functions take a filename (type file!),
>and do not require that you manage the file on the port level, for instance
>with respect to positioning, etc.
>
>
>Hope this helps.
>
>
>
>;- Elan >> [: - )]
>
>