TweetFollow Us on Twitter

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 or source 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.”


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 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)



- 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


Mach2, too, still has its active users; after mentioning the Mach2 compatibility problems with System 7, I received this letter:


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)

[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:


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 (now the star of the show), the DA, rewritten manual, updated glossary, the ReadMe application, a WhatIsNew text file for previous users, about a dozen examples, and every line of assembly source code (with instructions). Concurrent with the release, a new Rhine program (runs in color or black and white) was also released with an ad for Pocket Forth in it’s about box.

Pocket Forth’s new features: Fully compatible with System 7. High level events, balloon help, color icons (check out the girl in the DA), better menus, bugs fixed and numerous other enhancements have been added. Compatibility with release 4 and with all types of Macintosh (1984-1991) has been maintained.

Forth on the Mac scene, does indeed seem to be thinning out but with the work of us few, it is available, and being kept up to date. Recent coverage by the popular press suggests that efficient languages are no longer needed for general use, now that average memory sizes are measured in megabytes, and at 25 MHz even HyperCard is a speed daemon. Forth, however, is the language of choice for embedded systems.

[Of course the popular press is wrong, like so often. Even with fast machines, Hypercard is still slow if you do anything more advanced than opening a card by pressing a button. Mac users are used to immediate response (a point that is hard to get through to mainframe users), and even a 1/4 second delay between a user action and the program reaction can seem very slow. / JL]

While languages like C and Pascal are politically correct (and they carry their banners to battle), Forth is losing its religious zealots. No longer are there claims that Forth programs are half the size of assembly and run twice as fast. And improperly commented code is impossible to read, even if written in Forth. Other languages now base their popularity on the language itself, while Forth has become judged by its applications. I heard from somewhere that most of the experiments carried out on a recent space shuttle mission were written in Forth and that the software fix for the Hubble is also Forth.

It looks like Forth is very much alive, just used in different ways than it has been in the past. Keep up the good work and I’m looking forward to an all Forth article soon.

PS If you don’t have PF5 yet, let me know, I’ll get to you.”

Chris Heilman, Phoenix College, Chemistry:

Author of Pocket Forth

BITNET: heilman@pc (work) :

CompuServe: [70566,1474] (personal)

US Mail 85066-8345 (personal)

Listing: LS Fortran example code created by AppMaker
! Dispatcher.f -- dispatcher for windows and for modeless dialogs 
! Created 8/27/91 9:37 by AppMaker 
!!MP inlines.f
!!G JLtest.finc.f
!!S Dispatcher 

 Subroutine OpenWindows (fName, vRefNum, fRefNum)
 String*255 fName
 Integer*2 vRefNum, fRefNum
 Call OpenMainWindow (fName, vRefNum, fRefNum)
 End !OpenWindows

 Subroutine CloseCurWindow
 include ‘’
 if(cur^.windowKind = WMainWindow) Call CloseMainWindow 
 End !CloseCurWindow

 Subroutine MouseInContent (where, modifiers)
 include ‘’
 record /point/ where
 integer*2 modifiers
 if(cur^.windowKind = WMainWindow) Call MouseInMainWindow (where, modifiers)
 End !MouseInContent

 Subroutine TypeInWindow (ch)
 include ‘’
 character*1 ch
 if(cur^.windowKind = WMainWindow) Call TypeInMainWindow (ch)
 End !TypeInWindow

 Subroutine UpdateContent
 include ‘’
 if(cur^.windowKind = WMainWindow) Call UpdateMainWindow 
 End !UpdateContent

 Subroutine ActivateContent (activate)
 include ‘’
 logical activate
 if(cur^.windowKind = WMainWindow) Call ActivateMainWindow (activate)

 End !ActivateContent

 Subroutine ResizeContent
 include ‘’
 if(cur^.windowKind = WMainWindow) Call ResizeMainWindow 
 End !ResizeContent

 Subroutine ScrollWindow (newValue, oldValue)
 include ‘’
 integer*2 newValue, oldValue
 if(cur^.windowKind = WMainWindow) Call ScrollMainWindow (newValue, oldValue)
 End !ScrollWindow

 Subroutine DoControl (whichControl, whichPart, where)
 include ‘’
 record /ControlHandle/ whichControl
 integer*2 whichPart
 record /point/ where
 if(cur^.windowKind = WMainWindow) Call ControlMainWindow (whichControl, 
whichPart, where)
 End !DoControl

 Subroutine InitModelessDialogs
 End !InitModelessDialogs

 Subroutine CloseModelessDialog (whichDialog)
 pointer /dialogrecord/ whichDialog
 End !CloseModelessDialog

 Logical*2 Function FilterModeless (whichDialog, event, itemHit)
 pointer /dialogrecord/ whichDialog
 record /EventRecord/ event
 integer*2 itemHit
 End !FilterModeless

 Subroutine DoModelessItem (whichDialog, itemNr)
 pointer /Dialogrecord/ whichDialog
 integer*2 itemNr
 End !DoModelessItem

! MainWindow.f 
! Created 8/27/91 9:37 by AppMaker 

!!MP inlines.f
!!G JLtest.finc.f

!!S MainWindow 

 Subroutine OpenMainWindow (fName, vRefNum, fRefNum)
 include ‘’
 String*255 fName
 integer*2 vRefNum, fRefNum
 pointer /grafport/ newWindow
 record /rect/ bounds

 newWindow = GetNewWindow (MainWindowID, nil, INT4(-1))
 Call SetWTitle (newWindow, %ref(fName))
 Call SetPort (newWindow)
 Call SetNewInfo (newWindow)
 cur^.vScroll.Ctlh = nil
 cur^.hScroll.Ctlh = nil
 cur^.fileNum  = fRefNum
 cur^.volNum= vRefNum
 cur^.dirty = .false.
 cur^.filename.shdl = NewString (%ref(fName))
 cur^.windowKind = WMainWindow 
 cur^.text.TEH = nil
 !add code here: MainWindow open
 Call ShowWindow (newWindow)
 End !OpenMainWindow 

 Subroutine CloseMainWindow 
 include ‘’

 Call DisposHandle (cur^.filename)
 Call DiscardInfo (curWindow)
 !add code here: MainWindow close
 End !CloseMainWindow 

 Subroutine MouseInMainWindow (where, modifiers)
 include ‘’
 record /point/ where
 integer*2 modifiers
 record /rect/ bounds

 !add code here: MainWindow mousedown
 End !MouseInMainWindow 

 Subroutine TypeInMainWindow(ch)
 include ‘’
 Character*1 ch
 if (cur^.text.TEH = nil) then 
 Call SysBeep (INT2(1))
 Call TEKey (ch, cur^.text)
 end if
 !add code here: MainWindow keypress
 End !TypeInMainWindow 

 Subroutine UpdateMainWindow 
 include ‘’
 record /rect/ bounds
 Call DrawClippedGrow (Int2(-15), Int2(-15))
 !add code here: MainWindow update 
 End !UpdateMainWindow 

 Subroutine ActivateMainWindow (activate)
 include ‘’
 logical activate
 Call DrawClippedGrow (Int2(-15), Int2(-15))
 !add code here: MainWindow activate 
 End !ActivateMainWindow 

 Subroutine ResizeMainWindow 
 include ‘’

 !add code here: MainWindow items resize 
 End !ResizeMainWindow 

 Subroutine ScrollMainWindow (newValue, oldValue)
 include ‘’
 integer*2 newValue, oldValue
 !add code here: MainWindow scroll 
 End !ScrollMainWindow 

 Subroutine ControlMainWindow (whichControl, whichPart, where)
 include ‘’
 record /ControlHandle/ whichControl
 Logical*2 TrackButton
 External TrackButton
 integer*2 whichPart
 record /point/ where
 record /rect/ bounds

 End !ControlMainWindow 


Community Search:
MacTech Search:

Software Updates via MacUpdate

World of Tanks Generals guide - Tips and...
World of Tanks Generals is a brand new card game by the developer behind the World of Tanks shooter franchise. It plays like a cross between chess and your typical card game. You have to keep in consideration where you place your tanks on the board... | Read more »
TruckSimulation 16 guide: How to succeed...
Remember those strangely enjoyable truck missions in Grand Theft Auto V whereit was a disturbing amount of fun to deliver cargo? TruckSimulation 16 is reminiscent of that, and has you play the role of a truck driver who has to deliver various... | Read more »
The best GIF making apps
Animated GIFs have exploded in popularity recently which is likely thanks to a combination of Tumblr, our shorter attention spans, and the simple fact they’re a lot of fun. [Read more] | Read more »
The best remote desktop apps for iOS
We've been sifting through the App Store to find the best ways to do computer tasks on a tablet. That gave us a thought - what if we could just do computer tasks from our tablets? Here's a list of the best remote desktop apps to help you use your... | Read more »
Warhammer 40,000: Freeblade guide - How...
Warhammer 40,000: Freebladejust launched in the App Store and it lets you live your childhood dream of blowing up and slashing a bunch of enemies as a massive, hulking Space Marine. It's not easy being a Space Marine though - and particularly if... | Read more »
Gopogo guide - How to bounce like the be...
Nitrome just launched a new game and, as to be expected, it's a lot of addictive fun. It's called Gopogo, and it challenges you to hoparound a bunch of platforms, avoiding enemies and picking up shiny stuff. It's not easy though - just like the... | Read more »
Sago Mini Superhero (Education)
Sago Mini Superhero 1.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0 (iTunes) Description: KAPOW! Jack the rabbit bursts into the sky as the Sago Mini Superhero! Fly with Jack as he lifts impossible weights,... | Read more »
Star Wars: Galaxy of Heroes guide - How...
Star Wars: Galaxy of Heroes is all about collecting heroes, powering them up, and using them together to defeat your foes. It's pretty straightforward stuff for the most part, but increasing your characters' stats can be a bit confusing because it... | Read more »
The best cooking apps (just in time for...
It’s that time of year again, where you’ll be gathering around the dinner table with your family and a huge feast in front of you. [Read more] | Read more »
Square Rave guide - How to grab those te...
Square Rave is an awesome little music-oriented puzzle game that smacks of games like Lumines, but with its own unique sense of gameplay. To help wrap your head around the game, keep the following tips and tricks in mind. [Read more] | Read more »

Price Scanner via

13-inch 128GB MacBook Air now on sale for $79...
Best Buy has just lowered their price on the 2015 13″ 1.6GHz/128GB MacBook Air to $799.99 on their online store for Cyber Monday. Choose free shipping or free local store pickup (if available). Sale... Read more
Best Buy lowers 13-inch MacBook Pro prices, n...
Best Buy has lowered prices on select 13″ MacBook Pros this afternoon. Now save up to $200 off MSRP for Cyber Monday on the following models. Choose free shipping or free local store pickup (if... Read more
Cyber Monday: Apple MacBooks on sale for up t...
Apple resellers have MacBook Pros, MacBook Airs, and MacBooks on sale for up to $250 off MSRP for Cyber Monday 2015. The following is a roundup of the lowest prices available for new models from any... Read more
Cyber Monday: Apple Watch on sale for up to $...
B&H Photo has the Apple Watch on sale for Cyber Monday for $50-$100 off MSRP. Shipping is free, and B&H charges NY sales tax only: - Apple Watch Sport: $50 off - Apple Watch: $50-$100 off B... Read more
Cyber Monday: 15% off Apple products, and sto...
Use code CYBER15 on Cyber Monday only to take 15% on Apple products at Target, and store-wide. Choose free shipping or free local store pickup (if available). Sale prices for online orders only, in-... Read more
iPad Air 2 And iPad mini Among Top Five Black...
Adobe has released its 2015 online shopping data for Black Friday and Thanksgiving Day. The five best selling electronic products on Black Friday were Samsung 4K TVs, Apple iPad Air 2, Microsoft Xbox... Read more
All-in-one PC Shipments Projected To Drop Ove...
Digitimes’ Aaron Lee and Joseph Tsai report that all-in-one (AIO) PC shipments may drop a double-digit percentage on-year in 2015 due to weaker-than-expected demand, although second-largest AIO make... Read more
Sprint Offers iPad Pro
Sprint now offers Apple’s new iPad Pro with Wi-Fi + Cellular, featuring a 12.9-inch Retina display with 5.6 million pixels. Customers can pick up iPad Pro at select Sprint retail locations. It can... Read more
Cyber Monday: Target offers 15% discount on A...
Target has discounted Apple Watches by 15% for Cyber Monday. Choose free shipping or free local store pickup (if available). Sale prices for online orders only, in-store prices may vary: - Apple... Read more
Sunday roundup of Holiday weekend Mac sales:...
Take up to $500 off MSRP on the price of a new Mac at B&H Photo today as part of their Black Friday/Holiday weekend sale. Shipping is free, and B&H charges NY tax only. These prices are... Read more

Jobs Board

*Apple* Site Security Manager - Apple (Unite...
# Apple Site Security Manager Job Number: 42975010 Culver City, Califo ia, United States Posted: Oct. 2, 2015 Weekly Hours: 40.00 **Job Summary** The Apple Site Read more
iOS Wallet & *Apple* Pay Engineer - App...
# iOS Wallet & Apple Pay Engineer Job Number: 40586801 Santa Clara Valley, Califo ia, United States Posted: Nov. 16, 2015 Weekly Hours: 40.00 **Job Summary** The iOS Read more
*Apple* Online Store Expansion - Apple (Unit...
# Apple Online Store Expansion Job Number: 41191932 Santa…1, 2015 Weekly Hours: 40.00 **Job Summary** The Online Apple Store is seeking a person to lead its Read more
Software Engineer, *Apple* Watch - Apple (U...
# Software Engineer, Apple Watch Job Number: 38181776 Santa Clara Valley, Califo ia, United States Posted: Nov. 2, 2015 Weekly Hours: 40.00 **Job Summary** The Apple Read more
Technical Program Manager, Strategic Merchant...
# Technical Program Manager, Strategic Merchants - Apple Pay Job Number: 44001177 Santa Clara Valley, Califo ia, United States Posted: Oct. 30, 2015 Weekly Hours: 40.00 Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.