FORTRAN, AppMaker
Volume Number: 7
Issue Number: 10
Column Tag: Jörg's Folder
Language Systems FORTRAN and AppMaker 
Jörg Langowski, MacTutor Editorial Board
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
After the comparative review of LS FORTRAN and Absoft MacFORTRAN, I received
an invitation from Language Systems to review their interface to AppMaker, which
simplifies creating Macintosh applications in Fortran a great deal. So here we go. First,
even though AppMaker has been mentioned in our magazine, I’d like to remind you
briefly what it does.
AppMaker, from Bowers Development, is one of several products that lets you
create a user interface graphically, and when you are satisfied with the ‘look and feel’
of your program, create source code for a variety of programming languages. That
source code, compiled and linked, will give a functional Macintosh application that has
Apple, File, and Edit menus, together with the menus that you have defined, the windows
have the correct basic behavior (e.g. grow, zoom, and resizeable scroll bars), desk
accessories are supported and the whole thing is Multifinder compatible, etc. To make
the controls and menu selections do something useful, you then have to add your own
code that defines the actual functions of the different parts of the user interface.
AppMaker stands out from other programs (such as Prototyper) that do similar
things in that it only controls the way certain predefined code segments are plugged
together to make the application. These code segments are partially contained in
libraries, for the code that is common to all applications, and in string resources in
AppMaker itself, for code that changes depending on the user interface. If you are not
satisfied with the way AppMaker creates the user interface, you can change any of these
resources or libraries, because the source code is provided. And, most important,
adding code generation for a new language becomes more or less straightforward
(although I think adding a Forth interface to AppMaker would take too much of my spare
time).
Among the Fortrans for the Mac, the great advantage of LS Fortran is that
Structure and Pointer definitions are available (even with some amount of type
checking), which makes it very easy to create code that uses the Mac Toolbox interface.
Thus, with AppMaker being around, Language Systems could easily add their own code
generation part. It has been available for a while as “Fortran Tools for AppMaker”.
“Do-Nothing” example in LS Fortran/AppMaker
To see what Fortran Tools for AppMaker can do, I’ve created the simplest
‘do-nothing’ example application; it has Apple, File, and Edit menus, one resizeable,
zoomable document window, and a couple of standard alerts, such as an About box. It can
open and save documents, but does nothing with its contents; saved documents are
empty. In order to create an application which does something useful, you have to insert
your own code into the AppMaker-generated files in appropriate places. These places
are usually well-marked (see listing).
I’ve reprinted some of the AppMaker-generated Fortran code in the listing (not
all of it, that would be too long). In our example you see the central ‘dispatcher’ which
calls event handlers for the various windows and modeless dialogs that could be present
(only one in our case). The actual event handling routines are contained in the file
MainWindow.f that is listed after the dispatcher. The logic is quite clear: the dispatcher
decides which window the event belongs to, and calls the handler for that window. Who
calls the dispatcher? It is called from the main event loop. Because all the behavior
particular to the application can be put into the dispatcher and menu handler (not
listed), the main event loop never changes, and its code can be contained in a library.
When you purchase Fortran Tools, you get its source code, but I can’t list it here for
copyright reasons.
Thus you see, AppMaker gives you control over all details of the generated code.
For instance, it wouldn’t be too difficult to change the structure of the main event loop
and the dispatcher code pieces to account for high-level events as required by System
7-aware applications. (For those of you who haven’t read through the System 7
documents: a high-level event can be sent from one application to another and, for
instance, cause that application to open a document, or quit. An application can also sent
such an event to itself; instead of calling a ‘Quit’ handler directly when quit is selected
from the File menu, the application will send a ‘quit’ event to itself, and the high-level
event handler will do the actual quit actions. More on this in my next column).
Language Systems include several examples, where the simple do-nothing
application has been extended for displaying graphics, handling text edit fields, etc., by
adding only very few lines of Fortran code. Whatever your opinion (or religion) about
Fortran as a programming language is, with LS Fortran and AppMaker you can certainly
create application as easily and as well-documented as in Pascal or C. With the amount
of scientific applications written in Fortran, the LS Fortran / AppMaker team is a very
important tool that I recommend to anyone who considers transporting Fortran
programs to the Mac.
In the near future you can expect more developments in LS Fortran, as I was told
in a recent letter from Language Systems:
“The integration of AppleEvents and Publish & Subscribe into FORTRAN
programs was certainly the most popular part of our preview [at MacWorld Expo -
JL].
one of our demos launches Excel via AppleEvents and directs it to open two
documents. These documents subscribe to a data file published by the FORTRAN
program. By selecting a menu item from our output window the user causes the
published data file to be updated with random data. In the background Excel can be seen
to update its worksheet and chart to reflect the new values. Finally, when the user quits
the output window, Excel is also forced to quit via AppleEvents.
[I’m really sorry I can’t disclose the source code of that example here. It is
amazing how elegant the interface to the Edition Manager works - JL]
We have also been hard at work on new optimizations, including some technology
specific to the mc68040. We have improved our compatibility with Pascal and C and
also with other FORTRANs such as Cray and Data General. Debugging features have been
enhanced and the output window made more configurable.
The projected release date is early November, and we will send free upgrades to
registered owners who purchased after June 1st.”
Regards,
Guy McCarthy
Vice President
Research & Development
AppleLink: D1810 or LANGSYS
Forth mail
A couple of letters came in dealing with different Forths for the Macintosh (I
should write an all-Forth column soon again, I think). Bob Loewenstein gives an
update on the latest version of his Neon-successor, Yerk:
“Version 3.5 of Yerk, once known as Neon, is now available from anonymous ftp
at oddjob.uchicago.edu in ~ftp/pub/Yerk. There are 5 files:
0. ReadMe.txt description
1. manual1.sit.hqx no change from Yerk version 3.2
2. manual2.sit.hqx no change from Yerk version 3.2
3. yerk.3.5.sit.hqx all source files and executables
4. supp.sit.hqx supplemental files; no change from Yerk version 3.2
If you are picking Yerk off for the first time, you will want these files.
Even though not all of the source files have changed from version 3.3.2, I
recommend grabbing the yerk.3.5.sit.hqx file and archiving all of Yerk 3.3.2. Further
upgrades from 3.5 will be posted with an file consisting of only those files that have
been modified.
Version 3.5 is 32 bit clean and runs under system 7, but does not respond to
AppleEvents. You may now create a stand-alone application, though, and hooks are in to
help you make your program respond to High Level Events. See the ReadMe file and
source Events.
Yerk is an object oriented language based on a Forth Kernel with some major
modifications. It was originally known as Neon, developed and sold as a product by Kriya
Systems from 1985 to 1989. Several of us at The University of Chicago have
maintained Yerk since its demise as a product. Because of the possible trademark
conflict that Kriya mentions, we picked the name Yerk, which is at least not an acronym
for anything, but rather stands for Yerkes Observatory, part of the Department of
Astronomy and Astrophysics at U of C.
Some features of the language are:
- defaulted early binding, with ability to late bind in almost any circumstance
- inheritance (not multiple)
- floating point (SANE)
- many system classes and objects for mac interfacing: windows, controls, events,
files, arrays, ordered-columns, menus, hierarchical and popup menus, handles,
strings, mouse, quickdraw, modal dialogs, offscreen bitmaps, vbl, time manager,
etc.
- module (overlay) creation that are loaded only when necessary and may be
purged from application heap memory.
Some forth extensions are:
- local input parameters
- named input variables
- multiple cfa words (including vectors and values)
- CASE
- SELECT
- 68000 assembler
Yerk runs on all macs from mac+ on up, and under all systems > 5.x. If anyone
has any questions, feel free to contact me”:
Bob Loewenstein
Dept. of Astronomy and Astrophysics
University of Chicago
Yerkes Observatory
Williams Bay, Wisconsin 53191
414-245-5555
rfl@oddjob.uchicago.edu
Mach2, too, still has its active users; after mentioning the Mach2 compatibility
problems with System 7, I received this letter:
“Jörg,
I was very relieved when I saw your article in the July MacTutor. I was afraid
that you left the magazine since I had not seen your column in June. Reading your
column is the only reason that I subscribe to the magazine since I am an avid Forth fan.
[I see the hint - look for a new Forth column soon / JL]I am a scientist at the
University of Utah and ignore the snobbery of most Mac programmers with respect to
Forth. I am only interested in performance and Forth is by far the most productive
programming environment for someone like me who can only hack in his spare time.
Nevertheless, I have managed to create a sophisticated scientific program in MACH 2
Forth that has been commercially available for the last year.
The particular subject that prompted this note was your comment on the
incompatibility between System 7 and MACH2. This is only partially correct. In the
spirit of all true Forth hackers, I spent an afternoon modifying the system and it is now
completely compatible (at least I have compiled dozens of programs with it on a Mac
IIfx with System 7 without any problems at all). The modifications are really quite
minor. You must install a modified event loop to become fully multifinder compatible
(the one posted on the Genie bulletin board is *not* correct). Next you use ResEdit to
set the size resource to reflect the changes and install the screen font (monaco 9pt I
think) into MACH2 itself. Apparently MACH2 doesn’t believe in TrueType fonts.
Anyway, if your are interested in a “fixed” copy of MACH2 or a more detailed listing of
the changes necessary to patch MACH2, just let me know and I will be glad to send them
to you. [Definitely! E-mail is on its way / JL]I still do all my System 7 programming
in MACH2. By using the trap compiler that was posted on the Genie bulletin board, I
have implemented all of the new trap routines and have written programs that use
color, offscreen devices, palette animation and so forth. Since I can modify my system
(as you showed us how to do), I am always the first programmer I know who can use
new enhancements on the Mac...”
H. Steven Wiley (MacScientist)
Wiley@bioscience.utah.edu
[You might want to consider porting your code to MacFORTH since it is actively
supported.-ed]
The author of Pocket Forth, Chris Heilman, has some good news for us, too:
“Jörg,
I just got August’s MacTutor, opened it to page 58, just to see what’s up in the
world of Forth, and low and behold, there is my name right in the middle of the page! I’m
a star! Thank you for the mention ( “Starting with “!!!). [You’re welcome. Your
Forth is definitely one of the best ways for beginning and advanced hackers to get into
the guts of the machine / JL]
Last May, I (and a lot of others) upgraded our systems to 7.0. Of course the
compatibility checker had never heard of Pocket Forth (since I had never told Apple
anything about it.) So, cautiously, I began to check it out.
The DA dragged out of the suitcase and ran just fine, although I found the generic
icon to be kind of, well, generic. I put it through all the paces and tested the various
addressing modes. The DA passed. Then on to the application (which in systems 6 and
lower, I considered a poor cousin). First off neither it nor anything else would run in
the background; then I tried 32 bit addressing mode. /\/Crash-ola\/\ It was not a
pretty sight. I knew it would happen, but it was unpleasant to see it just the same. By
the time I had rebooted, release 5 was being hatched.
Pocket Forth release 5 has now been completed. Release date: 11 July 1991, the
date of the solar eclipse. Actually only a group of testers got it then, I put it on
CompuServe and America Online a couple of weeks ago. Since then a few hundred people
have received Pocket Forth, so it looks as if PASC’s statement that there is no market
for Forth is wrong (as long as the price is right). Pocket Forth is still priced within
the reach of every programmer (free), and support is more available than ever before.
I give out three addresses including CI$, Bitnet and mail. Anyone who gets it from
America Online can also contact me there.
The new release consists of a self extracting archive that contains the application