Hello, all, I see there are some true experts here on the forum, so maybe someone can help me.
I need to get output from DOS application that does some calculations based on the choices that user makes in it. Thre are 4-5 choices to choose, and then the calculated data is either printed or shown on the screen. Printing works just fine, however I have a problem with previewing data. I need to preview data becuase manytimes there isnt a printer to conencti notebook to.
The problem with previewing is that data listing is several pages long, and paging doesnt occur, so 90% of the data is just scrolled out, and only the bottom lines of the listing is visible. How can I capture the whole data?
Stuff like
App.exe > c:\text.txt
doesnt work. Also, I have failed to achieve this with System.Debugging.Process class. I can get output when the application is a command line application, and when application doesnt need user interaction. However, I have some menus in this app, and user needs to interact with them, in order to get the result.
Does anyone knows for sure if this is possible or not?
Thanks,
Goran
6 1528
You have a DOS application with menus?
Does it use like DOS4GW or some other gdfx library?
The process class can do standard streams for inpute/ouput/error, but that only works for commandline.
You could try using SendKeys(), but that might require a UI window.
No, no, it is a standard DOS menu, 1), 2), 3).... a), b), c), d). Application is written in Pascal 3.0,
I don't know what did you mean by SendKeys, but If you meant to use it for choosing options, then it is not needed. User will use keyboard to select options, and in the end there is option to print or preview, so when user presses V button, the data will be displayed on the screen. This is the moment when I need to start capturing data, after the user presses V (preview). Before that I am not interested what is going on. Data is several pages long, so I can see only the last page, like when you type Dir on a folder that has 100 items, only the last 30 (lets say) are visible.
Goran
Have you tried overriding the standard in/out/error streams in the Process class?
No, I have only tried with StartInfo and rediresting output, which is used for command libe applications. Can you point me to some direction, what is the idea/goal. and what I need to override.
Thanks,
Goran
Well here's an example for a program i wrote to wrap the nslookup dos command (Yes I know there is a built in version)
nslookup by itsels waits for the user to enter in some data before responding. Redirect the standardInput to send ascii data to the process.
I read it's reply with both the standardOut and standardError (since some information is sent on standard error) -
private string GetLookup(string IPAddy)
-
{
-
string retval = "";
-
//ProcessStartInfo psi = new ProcessStartInfo("nslookup", "");
-
psi.UseShellExecute=false;
-
psi.RedirectStandardOutput = true;
-
psi.RedirectStandardInput = true;
-
psi.RedirectStandardError = true;
-
// psi.CreateNoWindow = true;
-
Process p = new Process();
-
p.StartInfo=psi;
-
p.Start();
-
StreamWriter si = p.StandardInput;
-
StreamReader se = p.StandardError;
-
StreamReader so = p.StandardOutput;
-
si.WriteLine(IPAddy);
-
// si.WriteLine("blank");
-
si.WriteLine("exit");
-
retval += so.ReadToEnd();
-
retval += se.ReadToEnd();
-
-
while (!p.HasExited)
-
{
-
retval += so.ReadToEnd();
-
retval += se.ReadToEnd();
-
}
-
retval += so.ReadToEnd();
-
retval += se.ReadToEnd();
-
p.Close();
-
p.Dispose();
-
return retval;
-
}
-
You have confused me when you said "overriding". Yes, this is the code (more or less) I have used, but the problem with it is, when first options is chosed (a user types some letter), the process ends. I am not sure why, but I couldnt find a way to get around this.
Seems that I will get around with my problem with combination of two software - one that will redirect output from DOS printer to windows printer, and other that will convert this output to pdf format.
Thanks, Goran
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mark Wilson CPU |
last post by:
This must be easy, but I'm missing something...
I want to execute a Perl script, and capture ALL its output into a PHP
variable. Here are my 2 files:
-------------------------------------...
|
by: Steve |
last post by:
How can I read the output from a command line utility such as ping,
nslookup, etc, from within my app??? I know that it is possible to
output the results to a text file using the > function in a...
|
by: AMeador |
last post by:
I can see console output in the output window on VS, but how can you
see this text when running the app on a different machine or outside of
VS?
Thanks!
--- Andrew
|
by: Steve |
last post by:
I have created a console app that simply prints out a message a couple
times, then exits, here is the code:
<code>
for(int i = 0; i < 10; i++)
{
System.Threading.Thread.Sleep(500);...
|
by: lavu |
last post by:
I currently have a C# windows Application . I would like this App to
work through an command line interface also. I would like to specify
command line params, which should start the app and process...
|
by: tommaso.gastaldi |
last post by:
Hi
I am creating a pdf by just printing on Acrobat Distiller. This is
fine.
I need to create a pdf which has a given prespecified name and I do not
wish that
Distiller prompts me for a name....
|
by: garyusenet |
last post by:
Hi.
I am trying to learn about array lists, and found an example on MSDN. I
tried to compile it but it's not producing any output. I can't see why.
Any ideas?
Here is what I did.
1....
|
by: ptek |
last post by:
Hi,
I'm using Vstudio 2005 and I did a Windows Application project where I
also want to read arguments from command line and output some text
when appropriate (for example, typing the correct...
|
by: leonknathan |
last post by:
Hi,
I'm new to posting questions on this type of forum so if I'm doing something wrong i'll be grateful for any vats of common sense any of you can send in my direction.
I have a VBA question -...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |