I never really dealt with Fortran in university, and if I had, it probably
would have been in a Unix context. Anyone have some pointers to me on how to
process command-line switches in VMS from Fortran (I'm specifically tinkering
with f77, but I suppose f90 should do; it's a matter of environment)?
I guess it would be good to point out that I'm essentially a total neophyte
when it comes to working with systems that are not UNIX (or bare metal, or
classic Mac OS). Best I can tell is that I need to call either a SYS$ or
CLI$ library function, but I'm a bit lost in the giant manual and Google
doesn't seem to be helping me find sample code. The "standard" (which
probably means UNIX-standard) iargc() and getarg() functions don't seem to
work, at least not without some external library linked in, so I assume
those aren't the way to go.
Others have described how to do this by updating command tables or by creating
a foreign command. However, neither of these is entirely satisfactory on it's
own. (I will explain further if anyone is interested.)
It is possible to combine both methods to solve several problems. Create a
command definition file as would be used to update command tables but instead of
using SET COMMAND to update command tables, use SET COMMAND /OBJECT to create an
object file representation of the command definition. This is then linked with
the main programme written in Fortran or any other language. Even though a
foreign command is used to activate the programme (eg cmd:==$device:[dir]file),
it is also possible to call CLI$PRESENT, CLI$GET_VALUE and friends to have DCL
parse and validate the command. For a Fortran example of this technique, see:
http://www.tomwade.eu/software/superlock.html
(Unzip SUPERLOCK020.ZIP under VMS and use BACKUP SUPERLOCK020.A /SAVE [] /LOG
to extract the source.)
Regards,
Peter Coghlan.