home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
COMMIO0B.ZIP
/
TEXTDEV.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-05-05
|
4KB
|
110 lines
unit textdev;
{
This unit is a companion to the COMMIO communications unit.
Written by Jason Morriss a.k.a. Lief O'Pardy
Copyright (C) 1995,1996 by Jason Morriss
Including this unit in your main program source code allows you to use
TP's "write" & "writeln" procedures to do any output. It will output to
the remote and the local sides, just like if you were using the included
output routines in the COMMIO unit!
The only limitation on this method is that you can't put color/animation
codes in the string (like the putstr() proc), if you do they will be
displayed on both screens as normal text, you have to change the colors
by using the SetColor, SetFore, or SetBack procedures. Otherwise you must
use the "Putstr()" procedure to do color changing/animation within the
string. The syntax for using this method is:
write(SIO,'This is string 1.',' This is another...', ' A number:',12);
^^^- that SIO file is the important element to use this method.
You basically use the SIO variable just like if it were an actual text file.
But certain procedures like "close,append,reset,rewrite,etc" don't do
anything when called with SIO. (Rewrite actually DOES do something, but
its handled automatically by this unit, and once Rewrite is called once,
successive calls don't do anything more). The SIO file does not need to
be closed, TP will do that on its own when the program exits.
Do NOT try to use READLN() with the IO variable, it'll do NOTHING, and
you'll get unpredicted results from it.
}
interface
uses crt,dos,commio;
var
IOBuf : array[0..511] of char;
SIO : text;
{Procedure AssignIO;}
implementation
{───────────────────────────────────────────────────────────────────────────}
function IOnothing(var F:textrec):integer; far;
begin
IOnothing:=0;
end;
{───────────────────────────────────────────────────────────────────────────}
function IOinput(var F:textrec):integer; far;
begin
IOinput:=0;
end;
{───────────────────────────────────────────────────────────────────────────}
function IOoutput(var F:textrec):integer; far;
var i:word; {s:string;{}
begin
with f do begin
i:=0;
{}{ if BufPos>0 then begin
move(BufPtr^,s[1],BufPos); s[0]:=char(BufPos);
putstr(s);
end;{buffer must be 255 bytes big for this loop!}
while i<BufPos do begin
sioWriteC(BufPtr^[i]);
inc(i);
end;{}
BufPos:=0;
end;
IOoutput:=0;
end;
{───────────────────────────────────────────────────────────────────────────}
function IOclose(var F:textrec):integer; far;
begin
IOclose:=0;
end;
{───────────────────────────────────────────────────────────────────────────}
function IOopen(var F:textrec):integer; far;
begin
with f do begin
if mode=fminput then begin
InOutFunc:=@IOnothing;
FlushFunc:=@IOnothing;
end else begin
mode:=fmoutput;
InOutFunc:=@IOoutput;
FlushFunc:=@IOoutput;
end;
CloseFunc:=@IOnothing;
end;
IOopen:=0;
end;
{───────────────────────────────────────────────────────────────────────────}
Procedure AssignIO;
begin
FillChar(SIO, sizeof(SIO), 0);
with textrec(SIO) do begin
handle:=$FFFF;
mode:=fmclosed;
bufsize:=sizeof(buffer);
bufptr:=@buffer;
OpenFunc:=@IOopen;
end;
end;
{───────────────────────────────────────────────────────────────────────────}
begin
AssignIO;
SetTextBuf(SIO,IOBuf);{}
Rewrite(SIO);
end.