Mon, 20 Nov 2000 20:18:44 -0600
> Does anyone know if it is possible to call dos commands (i.e.
> dir, copy, mkdir, etc) from within a Ada program?
Of course it is possible; I've done it frequently.
Oh, you want to know how?
Well, there isn't any way to do it that uses only standard Ada facilities.
For most the items you mentioned above, it probably is best to code the
operation using a package defined by your compiler. Every compiler supports
a directory package, for instance (we also put one into Claw so that people
wouldn't have to depend on the compilers for this vital functionality).
[I've proposed standardizing such a package for the next version of Ada, but
of course that won't help you for a long time...]
To do what you asked for directly, you just need to spawn the command
processor with a command line of the command you want to execute. Your
compiler ought to have a package to spawn commands. (Note that this can be
tricky on some compilers; the command processor may not be named Command.Com
[as it can be replaced, and it is named Cmd.Exe on Windows NT]; it is best
to grab the name and path from the environment variable for that purpose.
This is the same procedure you need to use to run a batch file from an Ada
program. (Why would you want to run a batch file from an Ada program? One
reason is that you need to do so in order to create an Unininstall program
that cleans up everything [otherwise, you would have to leave it's