[comp.sys.ibm.pc] Turboc and Indirection

kalra@cit-vax.Caltech.Edu (Devendra Kalra) (06/02/87)

Could any one tell me how to indirect files when in turbo C integrated 
environment. Setting Command line to " < filename"does not help.

I used Instant-C also earlier and could not find a way to use indirection.

Thanks

markg@amd.UUCP (06/02/87)

In article <2898@cit-vax.Caltech.Edu> kalra@cit-vax.UUCP (Devendra Kalra) writes:
>Could any one tell me how to indirect files when in turbo C integrated 
>environment. Setting Command line to " < filename"does not help.
>

Within the Integrated Environment you can't via the Args option.

But, you could alway modify your program to look for args passed or include
the < filename on the command line (ie. tc sample.c <filename).  This will
pass filename to stdin.

If you don't believe it, try the following:

1. enter this program in via your editor. (call it sample.c)

#include <stdio.h>
main()
{
  char buffer[128];
  int numchars;

  while ((numchars = read(fileno(stdin), buffer, 128)) > 0)
    write(fileno(stdout), buffer, numchars);
}

2. go into TurboC with the following command line.

tc sample.c <sample.c

3. you will notice that the file sample.c is displayed on the screen and
   Turbo C is waiting for you to press any key.

NOTE:  This only works once.  You will have to exit and retype the command
       line to do it again.  This is because the redirected file is not 
       re-opened each time you run the program and TurboC didn't open it
       to start with, Command.com did.

-- 
 Mark Gorlinsky - AMD Processor Products Division/APPS SQA
 UUCP: {decwrl,ihnp4,allegra}!amd!markg
 AT&T: (408) 982-7811
 DISCLAIMER: My opinions are mine, not my employers. 

leder@ihlpm.ATT.COM (Leder) (06/03/87)

In article <4062@amd.UUCP>, markg@amd.UUCP (Mark Gorlinsky) writes:
> 1. enter this program in via your editor. (call it sample.c)
	<program is here> 
> 
> 2. go into TurboC with the following command line.
> 
> tc sample.c <sample.c
> 
Are you sure that tc did not ignore stdin and just look at the name on the
command line and load that program?  This seems like a more reasonable
explanation, particularly since BORLAND is not noted for using stdin for
getting keyboard characters and instead using INT 9 (I think that's the
keyboard, but I am too lazy to look it up).
>
> 3. you will notice that the file sample.c is displayed on the screen and
>    Turbo C is waiting for you to press any key.
> 
> NOTE:  This only works once.  You will have to exit and retype ...
>
This is greater proof of the loading of the file named on the command
line.  This is the same thing that Wordstar will do if a file name is
mentioned on the command line.

Bob Leder

markg@amd.UUCP (06/04/87)

In article <1155@ihlpm.ATT.COM> leder@ihlpm.ATT.COM (Leder) writes:
-In article <4062@amd.UUCP>, markg@amd.UUCP (Mark Gorlinsky) writes:
-> 2. go into TurboC with the following command line.
-> 
-> tc sample.c <sample.c
-> 
-Are you sure that tc did not ignore stdin and just look at the name on the
-command line and load that program?  This seems like a more reasonable
-explanation, particularly since BORLAND is not noted for using stdin for
-getting keyboard characters and instead using INT 9 (I think that's the
-keyboard, but I am too lazy to look it up).

Sorry you misunderstood.  The sample.c program will read stdin, tc will not.
That's why it worked.  Try using a different file for the indirection. You
will see that that file will be displayed and not sample.c.

>>
>> 3. you will notice that the file sample.c is displayed on the screen and
>>    Turbo C is waiting for you to press any key.
>> 
>> NOTE:  This only works once.  You will have to exit and retype ...
>>

-- 
 Mark Gorlinsky - AMD Processor Products Division/APPS SQA
 UUCP: {decwrl,ihnp4,allegra}!amd!markg
 AT&T: (408) 982-7811
 DISCLAIMER: My opinions are mine, not my employers. 

ccs016@deneb.UUCP (06/08/87)

> Could any one tell me how to indirect files when in turbo C integrated 
> environment. Setting Command line to " < filename"does not help.
> 
> I used Instant-C also earlier and could not find a way to use indirection.
> 
> Thanks

    I've been wondering if Borland had fixed that since Turbo Pascal.
Can anyone go in depth to Turbo C's relation with dos. Like will it
open a file that is given as a full path name?, redirection, pipes, macros,
etc ...
 
    "Ask before you buy"

Patrick Tully
pstully@ucdavis