🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.delphi.misc
5 messages
5 total messages Started by Hmmm Tue, 30 Mar 2004 17:38
redirecting standard I/O of console app from Parameters
#96
Author: Hmmm
Date: Tue, 30 Mar 2004 17:38
15 lines
1438 bytes
i wrote a console app with delphi 7
in prompt i coul write this

myapp.exe < data.in > result.out

so where there is readln in the code, this will be read from "data.in"
file, and where there is writeln, it will be write to "result.out"
file.

is there way to do this redirection without using prompt (When in
delphi IDE i press F9, standard input to come from data.in and so on).
In Run->Parameters... in Parameters text box i type this: < data.in >
result.out, but it doesnt work

any ideas?
Re: redirecting standard I/O of console app from Parameters
#97
Author: Bruce Roberts
Date: Tue, 30 Mar 2004 19:01
22 lines
2222 bytes
"Hmmm" <forums@mail.bg> wrote in message
news:aaa4810e.0403300938.68846eca@posting.google.com...
> i wrote a console app with delphi 7
> in prompt i coul write this
>
> myapp.exe < data.in > result.out
>
> so where there is readln in the code, this will be read from "data.in"
> file, and where there is writeln, it will be write to "result.out"
> file.
>
> is there way to do this redirection without using prompt (When in
> delphi IDE i press F9, standard input to come from data.in and so on).
> In Run->Parameters... in Parameters text box i type this: < data.in >
> result.out, but it doesnt work

It really depends on how the program is being run, since the runner is the
one that does the mapping. If you are running it from another program you
can use CreateProcess. A goggle search will turn up several examples of i/o
redirection using CreateProcess. As a general solution, you could have the
app parse the command line and do its own redirection.
Re: redirecting standard I/O of console app from Parameters
#98
Author: Hmmm
Date: Fri, 02 Apr 2004 09:17
12 lines
1523 bytes
This with Host application works, 
but i missed somethig in my prev post... i want to be able to set
breakpoints in my code. With host application the execution doesnt
stop at setted breakpoints.

so... to resume 
Is there a way, my app to get its standard input from file, and yet to
be able to set and use breakpoint.

PS: I could load the external file with AssignFile(File, FileName),
and replace all "ReadLn(myVar)" with "ReadLn(File, myVar)", but my app
expect its input to be redirected to it and i want to test this case
Re: redirecting standard I/O of console app from Parameters
#99
Author: Catherine Rees Lay
Date: Fri, 02 Apr 2004 09:48
23 lines
2066 bytes
In article <aaa4810e.0404020117.21546914@posting.google.com>, Hmmm 
<forums@mail.bg> writes
>This with Host application works,
>but i missed somethig in my prev post... i want to be able to set
>breakpoints in my code. With host application the execution doesnt
>stop at setted breakpoints.
>
>so... to resume
>Is there a way, my app to get its standard input from file, and yet to
>be able to set and use breakpoint.
>
>PS: I could load the external file with AssignFile(File, FileName),
>and replace all "ReadLn(myVar)" with "ReadLn(File, myVar)", but my app
>expect its input to be redirected to it and i want to test this case

Have you tried Attach to Process? (in the Run menu)

HTH,

Catherine.
-- 
Catherine Rees Lay
To email me, use my first name in front of the "at".
Re: redirecting standard I/O of console app from Parameters
#100
Author: Martin Harvey (Demon Account)
Date: Tue, 06 Apr 2004 22:09
39 lines
2359 bytes
On 30 Mar 2004 09:38:10 -0800, forums@mail.bg (Hmmm) wrote:

>i wrote a console app with delphi 7
>in prompt i coul write this
>
>myapp.exe < data.in > result.out
>
>so where there is readln in the code, this will be read from "data.in"
>file, and where there is writeln, it will be write to "result.out"
>file.
>
>is there way to do this redirection without using prompt (When in
>delphi IDE i press F9, standard input to come from data.in and so on).
>In Run->Parameters... in Parameters text box i type this: < data.in >
>result.out, but it doesnt work
>
>any ideas?

Horrible hacky way:

Yes, when you want to run the program, set it up instead to run:

cmd /c myapp.exe < data.in > result.out

or if you're using the older family of 32 OS's then do

dosprmpt /c myapp.exe < data.in > result.out

and that should do the trick - you need to use the part of the "run"
dialog that allows you to execute an arbitrary executable.

You'l have trouble debuggin your own app.

Nice pleasant way:

get your program to take command line parameters, and get it to do the
file I/O itself.

MH.
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