Sign in to follow this  
FenixRoA

Unity .Net and console communication

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this