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

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 (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
!----------
!!D+
!!R+
!!OV+
!!S Dispatcher 

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

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

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

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

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

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

 End !ActivateContent

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

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

!----------
 Subroutine DoControl (whichControl, whichPart, where)
 include ‘Globals.inc’
 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

!!D+
!!R+
!!OV+
!!S MainWindow 

!----------
 Subroutine OpenMainWindow (fName, vRefNum, fRefNum)
 include ‘Globals.inc’
 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 ‘Globals.inc’

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

!----------
 Subroutine MouseInMainWindow (where, modifiers)
 include ‘Globals.inc’
 record /point/ where
 integer*2 modifiers
 record /rect/ bounds

 !add code here: MainWindow mousedown
 End !MouseInMainWindow 

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

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

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

!----------
 Subroutine ResizeMainWindow 
 include ‘globals.inc’

 !add code here: MainWindow items resize 
 End !ResizeMainWindow 

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

!----------
 Subroutine ControlMainWindow (whichControl, whichPart, where)
 include ‘globals.inc’
 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

Latest Forum Discussions

See All

Six fantastic ways to spend National Vid...
As if anyone needed an excuse to play games today, I am about to give you one: it is National Video Games Day. A day for us to play games, like we no doubt do every day. Let’s not look a gift horse in the mouth. Instead, feast your eyes on this... | Read more »
Old School RuneScape players turn out in...
The sheer leap in technological advancements in our lifetime has been mind-blowing. We went from Commodore 64s to VR glasses in what feels like a heartbeat, but more importantly, the internet. It can be a dark mess, but it also brought hundreds of... | Read more »
Today's Best Mobile Game Discounts...
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Nintendo and The Pokémon Company's...
Unless you have been living under a rock, you know that Nintendo has been locked in an epic battle with Pocketpair, creator of the obvious Pokémon rip-off Palworld. Nintendo often resorts to legal retaliation at the drop of a hat, but it seems this... | Read more »
Apple exclusive mobile games don’t make...
If you are a gamer on phones, no doubt you have been as distressed as I am on one huge sticking point: exclusivity. For years, Xbox and PlayStation have done battle, and before this was the Sega Genesis and the Nintendo NES. On console, it makes... | Read more »
Regionally exclusive events make no sens...
Last week, over on our sister site AppSpy, I babbled excitedly about the Pokémon GO Safari Days event. You can get nine Eevees with an explorer hat per day. Or, can you? Specifically, you, reader. Do you have the time or funds to possibly fly for... | Read more »
As Jon Bellamy defends his choice to can...
Back in March, Jagex announced the appointment of a new CEO, Jon Bellamy. Mr Bellamy then decided to almost immediately paint a huge target on his back by cancelling the Runescapes Pride event. This led to widespread condemnation about his perceived... | Read more »
Marvel Contest of Champions adds two mor...
When I saw the latest two Marvel Contest of Champions characters, I scoffed. Mr Knight and Silver Samurai, thought I, they are running out of good choices. Then I realised no, I was being far too cynical. This is one of the things that games do best... | Read more »
Grass is green, and water is wet: Pokémo...
It must be a day that ends in Y, because Pokémon Trading Card Game Pocket has kicked off its Zoroark Drop Event. Here you can get a promo version of another card, and look forward to the next Wonder Pick Event and the next Mass Outbreak that will be... | Read more »
Enter the Gungeon review
It took me a minute to get around to reviewing this game for a couple of very good reasons. The first is that Enter the Gungeon's style of roguelike bullet-hell action is teetering on the edge of being straight-up malicious, which made getting... | Read more »

Price Scanner via MacPrices.net

Take $150 off every Apple 11-inch M3 iPad Air
Amazon is offering a $150 discount on 11-inch M3 WiFi iPad Airs right now. Shipping is free: – 11″ 128GB M3 WiFi iPad Air: $449, $150 off – 11″ 256GB M3 WiFi iPad Air: $549, $150 off – 11″ 512GB M3... Read more
Apple iPad minis back on sale for $100 off MS...
Amazon is offering $100 discounts (up to 20% off) on Apple’s newest 2024 WiFi iPad minis, each with free shipping. These are the lowest prices available for new minis among the Apple retailers we... Read more
Apple’s 16-inch M4 Max MacBook Pros are on sa...
Amazon has 16-inch M4 Max MacBook Pros (Silver and Black colors) on sale for up to $410 off Apple’s MSRP right now. Shipping is free. Be sure to select Amazon as the seller, rather than a third-party... Read more
Red Pocket Mobile is offering a $150 rebate o...
Red Pocket Mobile has new Apple iPhone 17’s on sale for $150 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Switch to Verizon, and get any iPhone 16 for...
With yesterday’s introduction of the new iPhone 17 models, Verizon responded by running “on us” promos across much of the iPhone 16 lineup: iPhone 16 and 16 Plus show as $0/mo for 36 months with bill... Read more
Here is a summary of the new features in Appl...
Apple’s September 2025 event introduced major updates across its most popular product lines, focusing on health, performance, and design breakthroughs. The AirPods Pro 3 now feature best-in-class... Read more
Apple’s Smartphone Lineup Could Use A Touch o...
COMMENTARY – Whatever happened to the old adage, “less is more”? Apple’s smartphone lineup. — which is due for its annual refresh either this month or next (possibly at an Apple Event on September 9... Read more
Take $50 off every 11th-generation A16 WiFi i...
Amazon has Apple’s 11th-generation A16 WiFi iPads in stock on sale for $50 off MSRP right now. Shipping is free: – 11″ 11th-generation 128GB WiFi iPads: $299 $50 off MSRP – 11″ 11th-generation 256GB... Read more
Sunday Sale: 14-inch M4 MacBook Pros for up t...
Don’t pay full price! Amazon has Apple’s 14-inch M4 MacBook Pros (Silver and Black colors) on sale for up to $220 off MSRP right now. Shipping is free. Be sure to select Amazon as the seller, rather... Read more
Mac mini with M4 Pro CPU back on sale for $12...
B&H Photo has Apple’s Mac mini with the M4 Pro CPU back on sale for $1259, $140 off MSRP. B&H offers free 1-2 day shipping to most US addresses: – Mac mini M4 Pro CPU (24GB/512GB): $1259, $... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.