.Net and console communication

Started by
2 comments, last by FenixRoA 16 years, 11 months ago
OK, this is the second thread on GameDev that I'm making that has little to do with game development and I apologize, but promise this trend will not continue. My issue is simple in nature but may be altogether impossible to do the way I want. I have been given an old Fortran console application. I wish to use C#/VB to make a GUI for this program. I need to be able to call this program. This is not a problem as I know I can just instantiate a process object. However, after I do so, and start the program, I need to be able to monitor it's progress and communicate with it. So here's the kicker. The main guy says that they REALLY don't want me touching the Fortran code, as they have it exactly the way they want it. So, here's my options as I see it: start the process as hidden so the console is running the background and feed information to it as necessary, or read the results back when they are available (Which I don't know if it is possible). -OR- I can go to the "main guy" and say something along the lines of "This section of the Fortran code simply guarentees that you get information into these variables and makes the following function calls. I can save this structure as is, but I need to change the way your variables get their values (such as from command line arguments) and the way the program stores the results." I would much rather prefer the first option. So if you guys have any suggestions/recommendations on how this can be done that would be great! I'm meeting with him on tomorrow, but that is in no way a deadline. It would be a good opportunity to bring it up though, so please help if you know anything about this! Thanks, as always your help is appreciated, ~F
Advertisement
I have absolutely no experience with this, and I don't know if this is what you're looking for, but you can redirect the standard input and output stream when starting a process, so you should be able to communicate with a console application this way. If this is what you need, look for ProcessStartInfo.RedirectStandardInput and ProcessStartInfo.RedirectStandardOutput.
Quote:Original post by SamLowry
If this is what you need, look for ProcessStartInfo.RedirectStandardInput and ProcessStartInfo.RedirectStandardOutput.


Thanks SamLowry. I'll have a look at this right now, and post here whether or not that's what I'm looking for.
PERFECT. Thanks so much Sam!

This is exactly what I needed. Much appreciated man.

Thanks for the tip!

Anyone who's interested in this, should read up further on the ProcessStartInfo class available on the microsoft site:
http://msdn2.microsoft.com/en-us/library/system.diagnostics.processstartinfo_members.aspx

I hope links to outside sites are allowed here.. Hope I'm not breaking a rule

This topic is closed to new replies.

Advertisement