Numerical Recipes in C for Macintosh

Earle R. Horton earleh at eleazar.dartmouth.edu
Thu Sep 8 12:25:39 AEST 1988


In article <3874 at bsu-cs.UUCP> dhesi at bsu-cs.UUCP (Rahul Dhesi) writes:
>In article <1415 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
...
>[code for Macintosh that reads a line, splits into arguments]
...
>How do we use wildcards then?

     Many methods come to mind.  You can parse the command line, then
use system calls to find which files exist, filling in the wild cards.
Alternately, you can purchase a command line interpreter or alternate
shell which supports command lines.  For programs which must have
main(argc,arcv) (or which I am too lazy to rewrite) I run the program
as an MPW Shell Tool.  The MPW Shell provides a UNIX-like environment
with command line arguments, fake pipes, and all sorts of goodies too
numerous to mention here.  The preferred method is to take the main()
function from Numerical Recipes or whatever source, and make it into a
subroutine which is called by a mouse and menu event parser which you
write.  The Finder also provides a function, GetAppFiles(), which can
be used to fill in the argument list prior to calling main().

     The programmer interface to the Macintosh does not readily
support the concept of a command line, but there are many ways for a
clever programmer to implement it.  Published or public domain code
can then be readily transported to the Macintosh with varying degrees
of extra work for the programmer.  Usually this means NO extra work if
you purchase a shell.  A separate book on Numerical Recipes for the
Macintosh is therefore NOT required, but books on how to use the
Macintosh-specific user interface usually are if you want to make your
programs visually appealing or use graphics, menus, etc.

>And what happens if program A wants to invoke program B and supply it
>arguments?

     This is possible, but is considerably more complicated than
system("program arg1 arg2 ...").  If you purchase a good shell
program, this is rarely necessary since you can write shell scripts to
do this kind of thing.

     The Macintosh provides a very different set of constraints for
programmers to work within, and provides different capabilities from
those which UNIX and other system users are typically accustomed to.
Nevertheless, this machine can be used as a serious number-crunching
tool, particular if you get one with the MC68881 numeric data
processor installed.  You can also draw pretty pictures at the same
time, and with much less work than on other graphics-oriented systems,
once you get the hang of it.

     Programs which use main(argc,argv) and which make the results of
their computations known by piping stdin to stdout can in most cases
be directly compiled and run using one of the another of the commonly
available development systems or shells.  On the Macintosh, such
programs tend to be boring in comparison with programs specially
written to manipulate windows, menus, Icons, and all that stuff
directly.  You can, however, have both.
Earle R. Horton. 23 Fletcher Circle, Hanover, NH 03755
(603) 643-4109



More information about the Comp.lang.c mailing list