Thread View: net.micro.pc
7 messages
7 total messages
Started by David W. Barts
Tue, 21 Oct 1986 05:12
I/O redirection in Turbo Pascal
Author: David W. Barts
Date: Tue, 21 Oct 1986 05:12
Date: Tue, 21 Oct 1986 05:12
30 lines
1682 bytes
1682 bytes
If you have tried it, you know that it doesn't work. Coming
from a UNIX environment, where redirection works for programs
written in any language, I find this very disturbing. My question
is, is there an easy way to write Turbo programs that send
output to standard output so that <, >, and | work?
I have tried using the intr($21, ) call for this. It works,
but then there's the problem of echoing standard input. You
can either ALWAYS echo stdin (AH = 01, not what I want if stdin is
a file), or NEVER do it (AH = 08, unacceptable if stdin is CON:)
What I am looking for is either
a. A way to tell if stdin is CON:, so I can then
echo or not echo as is appropriate, or
b. A way to do this WITHOUT having to resort to
issuing DOS interrupts in my Pascal code.
Please respond directly to me and not to the net as I am
years behind in reading net articles and probably won't get
caught up any time soon. In a few weeks I will summarize to
the net.
--
--David Barts N5JRN
... {cmcl2,ihnp4}!lanl!unm-la!cs457ab
... {ucbvax,gatech}!unmvax!unm-la!cs457ab
unm-la!cs457ab@lanl.arpa
University of New Mexico - Los Alamos
Re: I/O redirection in Turbo Pascal
Author: marms
Date: Tue, 21 Oct 1986 21:40
Date: Tue, 21 Oct 1986 21:40
11 lines
1179 bytes
1179 bytes
I ran into this "problem" myself some months ago. I wanted to pipe
the output of my Turbo Pascal program to a file (ie: "work.com > file").
After beating my head against a wall trying all kinds of things, I found
the simple answer in the book. There is a compiler directive to set the
I/O mode such that stdin and stdout can be redirected. I don't have the
book with me but it is probably either {$I-} or {$I+}. It could be one of
the other compiler directives, though. Check that chapter to know for sure.
Hope this has been some help.
Mike Arms
uucp: ...{ucbvax | ihnp4!lanl | gatech}!unmvax!sandia!marms
Re: I/O redirection in Turbo Pascal
Author: Stefan M. Vorkoetter
Date: Thu, 23 Oct 1986 14:53
Date: Thu, 23 Oct 1986 14:53
6 lines
869 bytes
869 bytes
Turbo Pascal does support I/O redirection. Simply make the first line of
the main program source file read,
{$G512,P512}
so that Turbo Pascal uses MS-DOS buffered output. I/O redirection works
fine then (except in compile to memory mode).
Re: I/O redirection in Turbo Pascal
Author: Dave Klotzbach
Date: Thu, 23 Oct 1986 16:37
Date: Thu, 23 Oct 1986 16:37
13 lines
1091 bytes
1091 bytes
> If you have tried it, you know that it doesn't work. Coming Could you possibly tell us which version of TP you ar using? If you are using a version less than 3. this is true, otherwise you simply have to set the buffers size for inp and out to greater than 1. See the common question section of your manual. This is covered in great detail. > Please respond directly to me and not to the net as I am > years behind in reading Due to the negative press TP has been getting lately I felt that this it is important to negate these complaints as publicly as they are aired.
Re: I/O redirection in Turbo Pascal
Author: T Anderson
Date: Thu, 23 Oct 1986 22:23
Date: Thu, 23 Oct 1986 22:23
12 lines
1100 bytes
1100 bytes
Starting with Turbo 3.0 there is a compiler directive that makes Turbo
use MS DOS I/O and then redirection works fine. I don't have my manual
with me so I do not remember the exact stuff, but its something like
(*$P512 $G256*) where the numbers are the sizes of the buffers you
want to use. $P is for output (put or something) and $G for input
(get). It does make all I/O somewhat slower as the overhead for an
MS DOS call is more than Turbo's direct I/O.
-- Terry L Anderson
AT&T Bell Laboratories
Liberty Corner, NJ
{ihnp4}!daimler!kaiser!tla
Re: I/O redirection in Turbo Pascal
Author: Bob Dea
Date: Fri, 24 Oct 1986 00:23
Date: Fri, 24 Oct 1986 00:23
3 lines
662 bytes
662 bytes
Turbo Pascal version 3.0 has support for I/O re-direction by way of
Compiler Directives {$Gxxx} for input and {$Pxxx} for output. I
have used this only in redirecting output to a file. Hope this helps!
Re: I/O redirection in Turbo Pascal
Author: S. John Banner
Date: Thu, 30 Oct 1986 04:39
Date: Thu, 30 Oct 1986 04:39
21 lines
1691 bytes
1691 bytes
In article <197@sandia.UUCP> marms@sandia.UUCP (Mike Arms) writes:
>I ran into this "problem" myself some months ago. I wanted to pipe
>the output of my Turbo Pascal program to a file (ie: "work.com > file").
>After beating my head against a wall trying all kinds of things, I found
Same Here.
>the simple answer in the book. There is a compiler directive to set the
>I/O mode such that stdin and stdout can be redirected. I don't have the
>book with me but it is probably either {$I-} or {$I+}.
Actually, you have to use the G, and P directives, to set file buffer
sizes, and if you want to send the output (or get the input), from a
device rather than a file ("uudecode < com1:", or whatever), you
also have to set another directive (B I think), otherwise it will reset
your buffers to 0 again. The I directive is strictly used to determine
what to do on an input error.
S. John Banner
UUCP: ...!uw-beaver!uvicctr!sbanner1
BITNET: ccsjb@uvvm
EAN: sbanner1@uvunix.uvic.cdn
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads