Writing GUI to output a text file and run a dos program to read it?

travanx

[H]ard|Gawd
Joined
Apr 9, 2000
Messages
1,579
I am going to start using an old dos program that is very cryptic to use. To sum it up it takes a text file that is really strangely written, does some math and outputs what I want. Can someone recommend what is easy to use to make an interface that I could make to have fill in boxes, drop down boxes, pick boxes with pictures next to it, and then have that fill in a txt file with the options picked and typed in?

One step further what would I use to make this text file and then run the program afterwards? Any help would be great on how to start this.
 
Easiest way I can think of off the top of my head would be to use php. You can make a little form webpage and post it to itself and then do the file io and a little manipulation if your up to it. Hardest part would be to actually setup everything to get started.

Another route may be to use visual basic, I'm not familar with it so I am not sure how easy of a solution though. And then you will need, uh, visual studio.

Probably not the best suggestions though ;o)
 
I don't know if this is a very good solution but you could surley do it in c/c++. File i/o would be done with ifstream and you could run the dos program with a fork() and execvp() (or similar.) As for the gui, gtk or the windows library from visual studio would work.

I hear visual basic is great for these kinds of quick apps that dont do much but need a gui. That may be worth looking into.

Using php is an interesting idea, and I just found out that php can execute and communicate with seperate processes yesterday when I was toying around with torrentflux, however, that would mean you need a web server running this program whenever you want to use it -- kind of annoying if you aren't planning on executing it remotely anyways.
 
Robizzle01 said:
Using php is an interesting idea, and I just found out that php can execute and communicate with seperate processes yesterday when I was toying around with torrentflux, however, that would mean you need a web server running this program whenever you want to use it -- kind of annoying if you aren't planning on executing it remotely anyways.

You can run PHP from a command line without a webserver.

If you want to quickly make a form I'd go with Visual Basic or C#. You can make a gui in no time flat with Visual Studio Express. It's also free. If a gui isn't that big of a deal, Python does an excellent job with strings and files and is very quick to write
 
Are you doing this for a desktop application/tool, or on a website?

If it's a desktop app, which language are you going to write your GUI in? Have you chosen one already, or do you need help with that, too?
 
TheDude05 said:
You can run PHP from a command line without a webserver.

I dont mean to derail this thread but could you shoot me a link or something about this? I dont understand how you would really do this. Do you run the php code which generates an html file, open the html file in a browser and then instead of clicking on any links/buttons on the page you go back to command line and compile the next php file? With the ease of installing apache these days I don't see any reason to do this.
 
Are you sure? The impression I have is that PHP.EXE runs as a CGI extension in response to any request for a *.PHP object sent to the web server. That means it's just reading from STDIN (and looking at the environment variables) and writing to STDOUT, just as you would if you ran it on a script from the command line.
 
Pretty positive. I've made php scripts for command line use before because I was more familiar with its string functions. (Granted I was doing this on Linux and not windows) If you execute a php script that has html in it or embeeded inside a html file, php passes the code just like normal, but obviously nothing is marked up because it just a terminal. (This doesn't always work though because CLI php uses different php.ini values) The link I posted could explain better than I ever could.

Its not nearly as robust on the commandline as other scripting languages are. They've managed to get it to run GTK guis.

EDIT: Here this explains it.

As of version 4.3.0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. As the name implies, this SAPI type main focus is on developing shell (or desktop as well) applications with PHP. There are quite a few differences between the CLI SAPI and other SAPIs which are explained in this chapter. It's worth mentioning that CLI and CGI are different SAPI's although they do share many of the same behaviors.

The CLI SAPI was released for the first time with PHP 4.2.0, but was still experimental and had to be explicitly enabled with --enable-cli when running ./configure. Since PHP 4.3.0 the CLI SAPI is no longer experimental and the option --enable-cli is on by default. You may use --disable-cli to disable it.

As of PHP 4.3.0, the name, location and existence of the CLI/CGI binaries will differ depending on how PHP is installed on your system. By default when executing make, both the CGI and CLI are built and placed as sapi/cgi/php and sapi/cli/php respectively, in your PHP source directory. You will note that both are named php. What happens during make install depends on your configure line. If a module SAPI is chosen during configure, such as apxs, or the --disable-cgi option is used, the CLI is copied to {PREFIX}/bin/php during make install otherwise the CGI is placed there. So, for example, if --with--apxs is in your configure line then the CLI is copied to {PREFIX}/bin/php during make install. If you want to override the installation of the CGI binary, use make install-cli after make install. Alternatively you can specify --disable-cgi in your configure line.



Judging from that, there are two different binaries. One for cgi/web stuff and one CLI.
 
PHP is quite commonly used for command line scripts on both *nix and windows, particularly among web developers turned server admins. I have a large set of scripts written in PHP on my work servers for adding users across our webmail, webcalander, samba, and shell access lists- all run from a command line. It's quick and dirty, but it gets the job done like any other scripting language.

I think the original mention of using PHP is far from that logic though. I believe Lord of Shadows was describing using PHP through a locally installed httpd to manipulate the text file through a web interface. Really, it's not a bad idea at all depending upon the need to distribute this application. Web based is nifty, even if it's local ;)
 
i better respond before this gets way off topic. :p Its to run an older engineering calculation program. And of course because old school engineers wrote all of this stuff and grew up on punchcards, well this stupid thing is still based on punch card inputs. To top it off its the only standard to use in Los Angeles county. So I am going to slowly be learning this program this or next month and the last thing I want to do is to memorize all the cryptic stuff and just make a GUI for me and the coworkers to use to speed this process up.

So now, its just an .exe that reads in a text file and outputs a text file and autocad .dxf drawing file. PHP sounds interesting as eventually running this stuff on the intranet server for reports and stuff sounds like something everyone would love, especially tying this into our projects list. But for now thats too far into what I would like to do.

So some simple interface to create a text file. Its been about 5 years since I learned C++ and Java. So something like visual basic is probably the answer. I just wasn't sure if there are other programs to use such as delphi, etc.
 
travanx said:
So some simple interface to create a text file. Its been about 5 years since I learned C++ and Java. So something like visual basic is probably the answer. I just wasn't sure if there are other programs to use such as delphi, etc.
Yep, Delphi still exists and is popular in some circles. I'm not sure what you expect for an answer when you don't know what language you're using.

In C++, you'd end up calling the Windows CreateProcess() API. This will run some other program. Other languages wrap this functionality in different ways, but they all end up calling CreateProcess() under the covers.

CreateProcess() allows you to specify what you'll pass for the command line. If your target program takes the input and output file names on the command line, just supply them in the command line you give to CreateProcess(). If the program has to read from stdin and write to stdout, things get a little more complicated. When you provide some details about your problem, I can help more.
 
TheDude05 said:
If you execute a php script that has html in it or embeeded inside a html file, php passes the code just like normal, but obviously nothing is marked up because it just a terminal.
Everything is marked up -- it's just that the terminal doesn't render the markups; it just prints them.

If you dig into it, I think you'll find that PHP is run as a command from the web server as I described, and is simply redirecting that output back to the client. It's then just a fancy CGI extension, which does everything with file streams and runs as a command.

SAPI support is indeed different; it's intended to provide a faster interface, since starting and stopping a process is very expensive. Keeping it running and talking to it with a persistent interface is far more efficient (on operating systems that support it). The SAPI version of PHP is implemented on Windows, for example, as a DLL because that's the best way to make the code persistently coexist with the web server process that's hosting it.
 
VB is the way to go for this kind of thing.

Heres a simple VB program which will capture some settings from a form and write them to a configuration file, then launch a DOS program.

You'll need to change the form design of course, and the paths for the settings file and dos program.

Dos Settings Example
 
did you just make that? thank you very much for that. At least I have something to try and figure out how to work off of it. :cool:

istymie said:
VB is the way to go for this kind of thing.

Heres a simple VB program which will capture some settings from a form and write them to a configuration file, then launch a DOS program.

You'll need to change the form design of course, and the paths for the settings file and dos program.

Dos Settings Example
 
Back
Top