TweetFollow Us on Twitter

Object Activities
Volume Number:4
Issue Number:7
Column Tag:Forth Forum

Objective Activities in Forth

By Jörg Langowski, MacTutor Editorial Board

Objects in Forth, International Resources & A Priority TaskScheduler

One of Forth’s great advantages is its extensibility. Since the Forth compiler is just made up from other Forth words, and the data structures into which each new word is compiled are very well documented and accessible to the user, you can very easily rewrite the compiler and thereby define your own language. (These comments are obvious to the seasoned Forth user; I’ve just repeated them to emphasize the difference to the more ‘canonical’ languages like Pascal or C).

With a language as flexible as Forth (very much like LISP in that aspect), it is no surprise that many have set out to create their own language on top of a Forth kernel. Famous examples are the object-oriented extensions ForthTalk and, of course, NEON. While ForthTalk (which has been covered by Paul Snively in MacTutor V3#2) seems to be alive and well, and still offered by Creative Solutions in their newsletter, NEON seems to have been all but abandoned by their creator, Kriya Systems. After the 2.0 update, more than a year ago, no more NEON news. And it was such an elegant implementation of object-oriented programming! Judged from bulletin board posts and letters I receive every now and then, many of you must be more than disappointed at the slow disappearance of NEON from the scene of Macintosh languages.

It is about a recent attempt to extend and -maybe- resurrect NEON, and about several other projects of object-oriented extensions to Mach2 Forth, that I wish to report this month. A lot of the information I am presenting comes from discussions and postings on the Mach2 roundtable on GEnie; therefore this column is, again, somewhat biased towards Mach2. MacForth users, please, read on and comment; a standard for an object oriented Forth would be appreciated by most of us.

Object Orientation in Forth

Why would one choose Forth to implement an object-oriented language? Besides the built-in extensibility of the Forth compiler, some aspects of object orientation are already contained in Forth. As a reminder, an object is a structure that contains not only data, but also procedures: methods, which can operate on the contents of the object or on other data. Example: an array of integer numbers which, given an index n, automatically returns the address of the nth element. The classical Forth definition of a ‘defining word’ for arrays with 32 bit-size elements is:

: ARRAY  CREATE ( # - ) 4 * ALLOT   
( reserves # cells in the dictionary )
DOES>  ( n <adr> - adr ) SWAP 4 * + ; 

The definition of an array of 100 long integer numbers would then be 100 ARRAY myArray, while 47 myArray puts the address of the 47th element of myArray on the stack. When the array is first defined, the CREATE part of the definition is executed, and space is reserved in the dictionary for the array’s contents. In object-oriented lingo, this would be called creation of an ‘instance’ myArray of the ‘class’ ARRAY. myArray’s ‘instance variables’ would correspond to the space reserved in the dictionary for the 100 32-bit numbers, and its one and only ‘method’ would be the DOES> part of the definition, which is invoked when the word myArray is executed.

If you now extend the definition ARRAY like this:

 DOES>  swap( n <adr> msg - adr ) 
 1 OF ( addr: ) SWAP 4 * + ENDOF
 2 OF ( at: ) SWAP 4 * + @ ENDOF
 3 OF ( to: ) SWAP 4 * + ! ENDOF

and define

: addr: 1 ;
: at: 2 ;
: to: 3 ;

47 addr: myArray would return the address of the 47th element, 47 at: myArray would return its value, and 3 47 to: myArray would store 3 in that cell.

myArray can therefore be viewed as an ‘object’ to which you can send ‘messages’ that determine the method used on its contents. myArray has three methods defined, addr:, at:, and to:, which have the method selectors 1, 2 and 3.

This example showed you one aspect of object-orientation, encapsulation of the data structures: you access the object’s data by an interface given by the messages that are sent to it. No other access would be possible (although in this case it is easy to circumvent that restriction, if one does it deliberately). The other aspect - not covered by the example - is inheritance of methods and data structures: we also need super- and subclasses, automatic message passing to classes further up in the hierarchy, method override, and so on.

Also, the example I gave resolves method references at run time (‘late binding’). This takes time, and if message and object are already defined at compile time, the compiler should resolve the reference so that the code generated for i at: myArray does not take any longer than a simple indexed fetch (like myArray i 4 * + @). This case is called ‘early binding’.

Let me now describe the three projects of object-oriented extensions for Mach2 that I’m aware of and their basic differences.

Object Oriented Extensions for Mach2

One attempt to create a NEON-like environment to Mach2 came from Aleksey Novicov, of Palo Alto Shipping, who developed a preliminary version of his object oriented system, called OPEX, whose syntax is very NEON-like. Following parts of Aleksey’s description of OPEX:

Brief Introduction to OPEX (v0.50):

An Object-oriented Programming Extension for MACH 2

Aleksey Novicov

OPEX contains all of the elements of an object-oriented programming environment. This includes the ability to define CLASSES, public OBJECTS of various classes, INSTANCE VARIABLES, and METHODS that are called by SELECTORS. Also, a class can be defined as having a SUPER CLASS,and thus inherit all of the data structures and methods of that super class. All of the method/object binding is currently static only (i.e., only compile-time binding, no run-time binding yet).

Two new vocabularies are present called OBJECTS and IVARS. In normal operation no special consideration need be given to these vocabularies. However, if any public objects are to accessed, then the OBJECTS vocabulary must always be present in the search order.

This a list of words that currently are available in OPEX :


Also, the following MACH 2 words have been enhanced to work with OPEX:


There are many things that still need to be implemented. Some of the obvious include dynamic binding, support of variable length ARRAYs, and dynamic object allocation on the heap. Also, the special objects, SELF and SUPER, still need to be implemented.

More extensive error handling will be implemented to aid the programmer. Hopefully, OPEX will become more robust as time goes on without sacrificing speed. Whatever the case however, it will still run quite fast by virtue of the subroutine-threaded FORTH that it was built upon.

The current version does not yet support multi-tasking. However, any programs written with OPEX that use a single task will work fine.” --Aleksey Novicov

In the following, some examples of actual OPEX code which shows the NEON-like syntax:

    2 BYTES    

    :M PUT:  MW!  ;M
    :M GET:  MW@  ;M

\ Class definitions must start with :CLASS, end with 
\ ;CLASS, and have a SUPER class.  Methods definitions 
\ must begin with :M and end with ;M.  Methods names must 
\ always end with a colon. MW! and MW@ respectively 
\ store and fetch a 16-bit integer to and from the object and 
\ data area that is pointed to by the topmost value on the 
\ object stack.

:CLASS Point <SUPER Object
    INT x
    INT y

    :M PUT:  PUT: y PUT: x  ;M
    :M GET:  GET: x GET: y  ;M

\ Selector or methods names can be reused without worry.  
\ The method of the class of a particular object will always 
\ be correctly called.

 ( for use with QuickDraw regions )
    LongINT RgnHandle
    :M OPEN:   CALL NewRgn  RgnHandle !  
 CALL OpenRgn  ;M
    :M CLOSE:   RgnHandle @  CALL CloseRgn  ;M
    :M DRAW:   RgnHandle @  CALL FrameRgn  ;M
    :M PAINT:   RgnHandle @  CALL PaintRgn  ;M
    :M ERASE:   RgnHandle @  CALL EraseRgn  ;M
    :M INVERT:   RgnHandle @  CALL InvertRgn  ;M

    :M WITHIN: ( ^location -- flag )
        @  RgnHandle @  CALL PtInRgn  ;M
    :M MOVE:{ dh dv -- }
        RgnHandle @  dh dv CALL OfSetRgn  ;M

\ In all of the above methods “GET: RgnHandle” could’ve 
\ been used instead of “RgnHandle @” and 
\ “PUT: RgnHandle” could’ve been used instead of 
\ “RgnHandle !”.  The advantage to accessing instance 
\ variables in this manner is speed.  Also note that any 
\ method can have its own set of local variables (see 
\ MOVE: method).

POINT thisPt
POINT thatPt

3 put:  x   4 put: y
get: x  get: y  put: thisPt ( set thisPt to some value )
get: thisPt swap put: thatPt  ( swap x and y for thatPt )

OPEX seems like one good step forward on the way to a NEON-like environment in Mach2, even though some things still need to be implemented. The discussion on OPEX has been pretty inactive for the last few months; I encourage all of you to contact the author or Palo Alto Shipping on the GEnie RoundTable to make this project advance.

The second OOPS-Forth that can be found on GEnie has been written by Jim Straus. His package is much less NEON-like. In his own words:


Jim Straus

“It is based on an article by Dick Pountain (of Byte fame) that appeared in the Journal of Forth Applications and Research (volume 3, number 3). The source code given in the article was modified to work with Mach2. This project was started because I’ve had a long standing interest in object oriented programming and I wanted an object oriented language where I could see what was going on inside. I started from the article by Dick Pountain so that I could see how someone else had done it. I figured that it would be easier to start with a basic outline for the extensions. While implementing this package, I have come across many things that I would do differently. Some of these include removing distinction between classes and instances, allow for “early binding”, and making the code for looking up method selectors much more efficient. I hope to get around to doing a second version, but I thought that people might want to try out an object oriented language in the mean time.

Included in this package are the files: ‘Object Oriented Forth-Mach’, which contains the defining words to create new classes and the definition of the root class %OBJECT. ‘Graphic Objects’ contains some demonstration classes and instances of those classes. The graphical objects are points, pens (which understand some Quick Draw messages, such as PenPat and many Logo turtle-like messages, such as right: and go:).

In an object oriented language you send messages to objects. The general syntax in this implementation is: <arguments> object \ methodselector

[different from the NEON syntax, which would be <arguments> selector: object --JL]

where the <arguments> depend on the method selected and “\” is the word that sends the message to “object” telling it to look for the method associated with “methodselector” and to execute the code for that method. In this implementation both classes and instances of classes are objects and may be sent messages. Classes define both the methods to which the class will responds and also the methods to which instances of that class will respond. [This is also different from NEON, where classes aren’t objects. --JL]

New classes inherit methods from their superclass. For example, the class %polygon defines its own methods, but polygons also recognize the methods of their superclass %pen. Also note that the class %polygon can override the methods in %pen to either replace or enhance them. The top of this hierarchy of classes is always the class %OBJECT. %OBJECT is special in that it handles creating new instances of a class, handles unrecognized method selectors and provides a general framework for what methods every object understands.

An instance of a class contains a pointer to its class and contains the actual storage needed by the instance. This allows each instance to have different values in its variables. For example, the two polygons “fred” and “sam” each understand all of the same methods, but when each is asked to “\ draw” itself, they display as different shapes and at different locations. This is because their values are different.

An object leaves its address on the stack. The word “\” (redefined from the Mach2 line commentor) calculates a hash value for the word following it (the method selector) and sends that value to the object. The object looks up the method selector with a case statement and executes its code. Any values needed by the method should be left on the stack beforehand. For example, “fred \ draw” would cause fred to draw itself and “10 bic \ go:” would cause bic to move 10 steps in whatever direction it was headed.” --Jim Strauss

Here is an empty class definition:

CLASS:- classname





A code fragment written in this dialect would look like:

CLASS:- %polygon


 INT INSTVAR SIDES ( number of sides in polygon )
 ( the length of the sides of the polygon )

 ~ init :: super\ init 20 LENGTH ! 4 SIDES ! ;;
 ~ print:: SIDES @ . LENGTH @ .
    super\ print
    .” \ length: \ sides: “ ;;
 ~ =    :: self \ class OVER \ related?
    IF DUP super\ =
 OVER \ sides SIDES @ = AND
 SWAP \ length LENGTH @ = AND
 ~ draw :: 168 ( 360d) SIDES @ / ( find angle )
    SIDES @ 0 DO
 LENGTH @ super\ go: DROP
 DUP self \ right: DROP
    LOOP DROP self ;;
 ~ go:  :: self \ length: \ draw ;;
 ~ sides: :: SIDES ! self ;;
 ~ sides:: SIDES @ ;;
 ~ length::: LENGTH ! self ;;
 ~ length :: LENGTH @ ;;
 ~ times: :: 168 ( 360d) OVER /
        SWAP 0 DO
 self \ draw DROP
 DUP self \ right: DROP
        LOOP DROP self ;;


call frontwindow call setport
100 100 %pen \ setcenter DROP 
 ( initialize the class %pen )
0 integer bic    ( create a variable for a new object )
%pen \ new bic to( an instance of class %pen )
0 integer fred   ( a variable for a new box )
%polygon \ new fred to  
 ( an instance of class %polygon )
0 integer sam
%polygon \ new sam to( create another polygon )
0 integer poly
%polygon \ new poly to  ( create another polygon )


This example - although incomplete - may give you an impression how OOPS Forth code looks like in Jim Straus’ system. I’ll leave it with that; for a complete description and the source code you should check on the Mach2 roundtable on GEnie.

The third Mach2-OOPS, written by Wayne Joerding from Pullman, WA, is similar to the one just described in that it uses class defining objects (CDOs) to create instances or subclasses of a class. Wayne has prepared, and almost finished, a big article on his implementation which we’ll hopefully print in one of the next issues. The implementation allows early and late binding. Again, a code fragment probably serves best to explain the syntax:

\ ====== Variable size Array Class =========
Integer Define.Child.Class
 I.Var  Max.Index
 \ max size of array, for error checking
 I.Var  Length   
 \ number of current elements in array,
 \ measured by cells
 I.Pntr Start    
 \ points to the start of array memory
 :M Describe
  .” ---- Instance Information --------------”
 cr .” Max Length in cells  = “ 
 Max.Index @ 1+ .
 cr .” Cell size in bytes   = “ Int @ .
 :M Store ( x i -- ) 
 \ Store value x in array for index = i,
 \  first cell has index of zero
 Max.Index @ over < over 0 < or IF 
 .” index out of bounds” abort THEN 
 \ <-- error checking
 Int @ * Start + ! ;
 :M Retrieve ( i -- )
 \ Retrieve value of array for index = i.
 Max.Index @ over < over 0 < or IF 
 .” index out of bounds” abort THEN 
 \ <-- error checking
 Int @  * Start + @;

 :M Make.Instance ( n c -- ) ( <name> -IN- )
 \ Array instance of size n cells, cell size of c
 CREATE immediate
 ins.Key @  
 ,  \ store key to methods of parent class
 dup ,  \ save cell size in ‘Int’ variable
 over 1-  , \ make and save Max.Index 
 \ of array for error checking
 0 ,    \ init current Length to zero
 * ins.Size @ + allot
 DOES> dup @ Selector( ins.PFA -- ins.PFA key )    
Integer Name.Child.Class  Array  ( n c -- )

You notice the strategy: The class INTEGER is just another object to which we can send the message Define.Child.Class, followed by a subclass definition; right after that definition, we send the message Name.Child.Class, followed by the subclass name. A bit unusual for those used to the NEON syntax, but it works very well. Typical code would look like:

\ -- Array test ----
100 Array Make.Instance myArray
3 47 myArray Store
47 myArray  Retrieve . cr

\ -- test of String ----
20 String Make.Instance StrHello
: hel .” This is StrHello” ;
‘ hel 4 + StrHello Store
: chk.StrOb StrHello Print ;

I hope you are anxious to see the actual article, which should follow soon.

NEON - still breathing (?!)

NEON’s problem has been - I think - to have been on the market too early; there were just too may bugs left in the first releases. NEON 2.0 always behaved quite nicely in my hands; others said it still crashed very often. Anyway, looking back one could perhaps consider NEON 2.0 the first mature release, and it is a shame that there has been only silence from Kriya Systems for so long.

Extending Neon

Jim Savidge

Recently, an avid NEON user, Jim Savidge, has taken the NEON kernel and built its own extensions on top of it, making it into an even more powerful system than NEON itself. I will give you a quick description of his enhancements.

(Excerpt from GEnie)

Category 2, Topic 14

Message 47 Sat Jan 02, 1988

J.T.SAVIDGE at 23:41 CST

For those who are interested I have made some very interesting and powerful extensions to Neon that might have some use in a Mach 2 implementation. I am at the moment trying to patch Neon to work on a Mac II. Now that Neon is no longer on the public market and that it uses self-modifying code etc.., wish me luck. I rather have my extensions in use in an expanding market. (hint hint Mach users) Here is a simple list of my extensions:

1) Multiple-inheritance w/ no limit to number of super classes, User can pick which class a message will be sent to, and which particular class variable it is sent to, (of the classes many superclasses.)

2) Private methods. The message name will no longer be recognized after the class definition is close off.

3) Local Procedures. At the Forth level. This allows a local Forth word, (a Forth definition inside a Forth definition) to access the local variables.

4) A multi-window, single-stepping debugger, with multiple levels of break-pointing. (i.e. breakpoint to test a word, pop into debugger while testing, breakpoint test, continue last break, then even go back to where you were on the first breakpoint, etc..) Windows include: trace window, Tib window with In indicator, Stack window that shows decompiled meanings of Parameter, Return, and Methods stacks.

5) Unique-methods. Creating a single object with methods of its own.

6) Clone-Object and Copy-Object words.

7) Echo-to-disk

8) Saving off of Method and Ivar names for later Decompiling/Debugging.

9) Other “minor improvements”.

If anybody would like me to contribute to an object-extension to Mach 2 or in creating any new Forth/Object language *PLEASE* contact me.

James T. Savidge, Saturday, January 2, 1988.

Even for those not directly interesting in object-oriented programming, the definitions for local procedures and the multi-window debugger should be very worthwhile enhancements. For the object-oriented part, the multiple inheritance - allowing a new subclass to have several superclasses - is, of course, especially interesting.

A message to an object that has several superclasses, and which cannot be handles by the object itself, is first passed to the superclass which is defined first, if the superclass cannot handle it, it is passed further upward in the hierarchy, until the class OBJECT. If the method still can’t be found, the message is passed to the superclass which was defined second, and so on. An example of a class definition in Jim Savidge’s enhanced NEON would look like:

:Class Qqq <Super Rrr
           <Super Sss
     Var Qqqvar

    :M Aaa: .” Qqq Message “ ;M


Qqq myObj

The message Aaa: can be handled directly by objects of class Qqq, while other messages are first passed to class Rrr, then to Sss. One more specialty is class picking; if you send Sss.Xxx: myObj, the message Xxx: will be passed directly to the superclass Sss.

Private methods which are only accessible from within the class definition can be defined through the following construct:


        :M AAA: .” AAA “ ;M
        :M BBB: .” BBB “ ;M

    :M CCC: .” CCC “ aaa: self ;M 
    :M DDD: .” DDD “ bbb: self ;M 



In this case, sending ccc: one would print ‘CCC AAA’, while aaa: one would result in an error message. A new level of information hiding which can be very useful.

I have tested all of the above, and more, on my MacII, and to my great surprise (I hadn’t tested NEON on the MacII yet) discovered that NEON 2.0 still runs on a MacII, even under Multifinder! It shouldn’t run, though, since my cache was turned on, and trap calls in NEON use self-modifying code (you know, the old trick where you drop the trap code just in front of your feet and step on it) so double surprise. Triple surprise, when Jim told me on the network that HIS MacII wouldn’t run NEON 2.0. Subtle differences in system configuration probably make a big difference here.

The 68020 instruction cache will allow to use self-modifying code, if an address has been executed beforehand that is equal to (modified address modulo cache length), since then the instruction that was modified will always be fetched from memory. If one can make sure that the self-modifying code has stepped through at least 64 32-bit instructions in linear sequence before encountering the modified address, this might work. I have traced the NEON code for signs of such a behavior, but no luck. Somehow it works on my MacII and crashes on Jim’s strange and mysterious things going on here.

I bet you’ll all like to see a full article on the NEON extensions. As Jim told me, that, or a commercial package, is under consideration, a lot depends on the availability of a more recent NEON release, or even the complete NEON source. The future of NEON should definitely not end at this point, and any support from outside can only help the issue.

Feedback Dept. Europe

International Conversion

Peter Freund


Here’s a letter from a reader in Sweden (again those international keyboards and characters ):

“I am one of those non-programming, yet admiring users, that enjoy MacTutor ‘cause there is something worth reading there.

I work for Software Plus, distributor in Sweden for several Macintosh and MS-DOS products. We represent products like TOPS, WriteNow, QuarkXPress, SuperPaint, Timbuktu, MacLink and companies like General Computer, SuperMac, Symantec (Living Videotext, Think Technologies), Farallon. I am the one that answers and handles communication products, but also companies “knowledge-base”. I also do some translation of programs and manuals.

I know that if an article (like mine) would be published in MacTutor, it would help spreading Macintosh on the international basis and also help our company (I would have less annoying work.) [Well, there you go! Take your vacation now --JL]

Take any text from the following letter, in any form, or please write any kind of program that shows how to use the “International Utility Package” (it ought to be quite easy) - so my and all non-english-spoken peoples’ job will be easier.

I also keep up a BBS (called Fenix) on a free basis when I am not working (using RedRyder Host). The number is +46 8 308356. (Either I or Fenix answers the phone.) My address is:

Software Plus
Att: Peter Freund
Box 2286
600 02 Norrköping
+46 11 181270
(leave a msg if I am not available)
+46 8 308356
(my usual number ((I work at home with translation of MORE right now)))

I also send some fun [a HyperCard stack for translating] I have created myself. Enjoy!

This is an article I have been wanting to write for a long time: Today 1988-10-05 (US format: 5/10/88...)

How to handle international characters

In the old days, before 8-bit-ASCII, different countries did their own modification to computers, so the national characters would work. In Sweden there even became two versions of 7-bit ASCII, “Swedish usual version” and “Swedish name version”.

For example the old Apple II was sold in Sweden with the following character set:

!”#$%&’()*+,-./ 0 9 : ; < = > ? @ A Y Z Ä Ö Å ^ _ ‘ a y z ä ö å ~

The ROM was specially modified for Sweden. The keyboard was also modified, in a similar way as a the swedish keyboard nowadays on a Macintosh.

Then came the Macintosh, with RAM-based fonts and complete 8-bit ASCII. Most of the european (all(?) west-european) characters can now be handled in a general way. This means that all well-written programs can be used internationally without modification.

Well, the problems are small compared to our friends in Norway and the IBM PC. When IBM designed their own version of 8-bit-ASCII, they “forgot” the norwegian/danish character Ø. (An error even Apple did with their early version of Courier in Apple LaserWriter ). This means that all ROMs in Norway/Denmark has to be specially made for any MS-DOS machine, and the two characters ¢ and ¥ is replaced by ø and Ø.

There exist more versions of 8-bit-ASCII (Digital Decmulti, Hewlett Packard Roman 8). PostScript use special names for characters. Now let us first look at Macintosh and IBM PC!

When translating between a Macintosh and a IBM PC, it is difficult to only use TOPS or Dynafile for text files. There has to be an international(!) version of MacLink for handling the international characters correctly. With Apple File Exchange for conversion between Apple II and Macintosh I probably obtain the usual []\ instead of ÅÄÖ.

For a very long time there was no program that correctly could use all 256 characters when communicating. Usually the program skipped everything above ASCII 127. Most program have an option nowadays (like Red Ryder 10.3) to turn masking of high bits off.

There is two programs on the Macintosh that handle communication with swedish characters correctly: MacTerminal (swedish version) and inTalk. The user can easily select if swedish (swedish 7-bit-ASCII) is to be used or not. In MacTerminal it is also possible to select if incoming characters, outgoing characters or both should be converted, and even both swedish standards are available.

How to communicate in Swedish?

I guess they use some kind of conversion table. If a Macintosh is to be used as a terminal to a mini in Sweden, there are two conversion tables necessary. Here is the scheme: First I press the swedish character Ä on my Macintosh. The Mac communication program checks if this character is anything that is used for terminal emulation. If not, we convert this character, using conversion table one, into a [. Then we send the character over.

When on the other hand the mini sends a character, we first check if it has anything to do with terminal emulation. Thereafter we convert the characters that is supposed to be sent to screen, using conversion table two.

When MacTerminal, or InTalk implemented the swedish character set, they did not let the user change the conversion tables. This means that if I want to communicate with a IBM PC and send text files over, I must use some special program again!

Does it really have to be that difficult? In MS-DOS-world there are several programs (Enable, ProComm, plus others), where it is easy to modify a conversion table, with all characters, any way I like. There even exists a TSR (Terminate and Stay Resident)-program (like an INIT) that patches the serial routines for Swedish, so the conversion almost always works.

It ought not to be too difficult to write a cdev that would alter the serial routines, in a similar way and that could be configurable/turned on/off through the Control Panel.

[Such a routine might actually be very useful in a number of circumstances. I can remember the case of Versaterm Pro v.2.0 not recognizing the new ISO Keyboard correctly (the one with the small return key). In that case, you wouldn’t be able to use the arrow keys anymore to walk across a VT100 screen. This problem has been solved in never versions of Versaterm, but for the meantime it would have been extremely useful to have a routine available that passes serial in/output through a conversion table like you suggested. If I can figure out how to do such a filter in a way that would satisfy the User Interface Thought Police, I might write a column on it].

To all hackers:

Yet what really would improve things would be if the manufacturers would think a little more internationally. (In Inside Mac there is an “International Utility Package” worth looking at!)

Now, let us look at some popular programs today (I guess most of you know them):

Very Good:

4th Dimension - sorts well, configurable, works even with chinese!

MacTerminal (swedish version).

QUED - sorts and works correctly.

MORE - sorts correctly, handles all characters/ date functions with class. But even the sun has its spots, I cannot use the name “Örjan” as registration name, because it starts with Ö.


WriteNow - can handle foreign characters, but the spelling-checker cannot suggest any foreign characters, and also cannot see the difference between upper case and lower case with international characters.

DiskTop - has a funny bug. Difficult to find by date, because DiskTop suggests international date format, but can only accept US-dates for input. (DiskTop 3.0.2)

Bad (most “famous” programs work pretty well nowadays):

FileMaker Plus - cannot sort correctly. For a DB-program, this is bad. (I think MS File, Reflex and Helix had/has(?) the same problem.)

Old MacPascal - not possible to write international characters at all (above 80 hex).

SuperPaint - cannot print on whole “A4 Letter size” (8 1/4" x 11 2/3").

RedRyderHost - uses a font that does not even contain ÅÄÖ.

A lot of programs use Command/] and Command/[ and other special characters for fast menu selection, that doesn’t work on international Systems.

Finally a suggestion to those “desktop publishing program”-makers that always seems to hunt for good, new features: “Overlay characters”!

Kerning is a modern thing nowadays. With kerning it is possible to combine two characters into one. In many languages it is very usual (as usual as an “e” in english) to combine normal letters (acenorsz) with characters like ´ ~^`´¨. [I recently found out to my surprise, when trying to type the address on a letter to Czechoslovakia, that Apple left out a c with an inverted circumflex, as shown below created in MacDraw, from their fonts. In fact, that diacritical mark does not seem to exist].

The problem with kerning in desktop publishing programs today is that a value has to be specified. Yet I in most (all?) cases want the top character to be centered above the lower one. I can, with some DTP-programs, put two characters in the same place with kerning, but when size or font changes, the position of the top character goes wrong..”

--Peter Freund

[Thank you, Peter, for these very interesting remarks on international compatibility issues, a specter that has haunted the Macintosh scene ever since this machine was introduced. The fact that changing keyboard layouts ‘on the fly’ became possible only with System 4.1 has always been embarrassing.

Note to our readers: Peter’s letter was accompanied by a file which contained the keyboard layout resources (KCHR) for over ten different countries. This file is included on this month’s source code disk for anybody who needs it. -JL]

A Priority Based Task Scheduler

Clive Maynard,

Western Australia

This contribution was sent to us from an Australian Macintosh user and Mach2 programmer. It implements a priority-based scheduling system for Mach2 tasks.

“Dear Jörg,

I have read your column in MacTutor for quite a time with considerable interest and have found it very useful.

I have enclosed on disk something which may be of interest to you for an article in MacTutor.

The software provides a demonstration priority based scheduler for Mach2.

The basic round robin is not removed for the Mach2 task and Editor together with a background scheduling task. Additional tasks are added in such a way that they put themselves to sleep on completion through the execution of a word SwitchTask and return control to the scheduler. The scheduler determines from the priorities of available tasks which should be woken next, puts itself to sleep and wakes up the correct task.

The result is that the minimum number of tasks are in the round robin when the normal Mach2 pause occurs.

Variations which could improve speed include coding the scheduling task in assembler but this was developed for student study of operating system functions not high performance.

Priorities may be changed through a Priority Terminal task window in the range 0 to 100. 0 corresponds to task suspension until the priority is raised back to a positive value. The initial default priority is 10 for each task.

[As you can see from the code, the scheduler creates a task table for a maximum of ten tasks. For each task, its current level, the priority value and its address are maintained in this table. The level is initialized to zero. In its main loop, the task scheduler decrements the level of each task by its priority value. Each time the decrement passes through zero, the task is woken up for one round of execution and the level reset to 100. --JL]

The three additional tasks run in the demonstration provide a simple quickdraw output. The tasks can have their priorities varied and easily show the effects of the priority allocation.

The only other features which may be of interest are:

1. The creation of a new word LVALLOT which allows for the creation of local arrays in words with local parameter and variable facilities.

2. #IN which is an intrinsic word in UR/FORTH for the IBM/PC is created here using LVALLOT and the SwitchTask function to prevent the suspension of the other tasks when new priority values are being entered.

Clive Maynard,

Wave=onic Associates

199 Watts Road,

Wilson 6107

Western Australia”

[One further remark is that one should minimize the use of PAUSE in this task-switching environment, and use SwitchTask instead to make the scheduling more effective. For this purpose, the word PTExpect redefines EXPECT to contain a SwitchTask. There are PAUSEs left (in ?TERMINAL and KEY), but this can’t be avoided.

The illustration shows the nice graphical output of Clive’s demo. --JL]

Fig. 2 Mach2 task scheduler output
(on JL’s usual crowded Multifinder desktop)

The Mach2 task scheduler

.( Priority based multitasking on the Macintosh ) cr
( Original concept: D.Bryant, G.Caunt, G.Else 1987 )
( Modifications and Generalisation: )
( C.A.Maynard 1988 Wave=onic Associates)
( Version 1.1 060488 )
( -------------------------------------------------------- )
( Task and window configurations for the necessary tasks )
( -------------------------------------------------------- )
400 1000 background schedulertask
400 1000 terminal prioritytask

new.window PriorityWindow
“ PRIORITIES” PriorityWindow Title ( create priority window )
40 250 110 500 PriorityWindow Bounds
Document Visible NoCloseBox GrowBox PriorityWindow Items
PriorityWindow Add
( -------------------------------------------------------- )
( DEMO Tasks and windows )
( -------------------------------------------------------- )
400 1000 terminal task1
400 1000 terminal task2
400 1000 terminal task3

new.window Task1Window
“ TASK 1” Task1Window Title ( create the TASK 1 window )
140 20 310 180 Task1Window Bounds
Document Visible NoCloseBox NoGrowBox Task1Window Items
Task1Window Add

new.window Task2Window
“ TASK 2” Task2Window Title ( create the TASK 2 window )
140 180 310 340 Task2Window Bounds
Document Visible NoCloseBox NoGrowBox Task2Window Items
Task2Window Add

new.window Task3Window
“ TASK 3” Task3Window Title ( create the TASK 3 window )
140 340 310 500 Task3Window Bounds
Document Visible NoCloseBox NoGrowBox Task3Window Items
Task3Window Add
( -------------------------------------------------------- )
( USER Variable definitions )
( -------------------------------------------------------- )
72 user TaskWindow
220 user rleft
224 user rright
228 user rtop
232 user rbot
236 user diff 
 ( create rectangle coords as user variables for each task )
240 user angle
244 user rectangle ( space for 8 bytes needed. Next slot 252)
( -------------------------------------------------------- )
( Scheduling Task Definitions )
( -------------------------------------------------------- )
 ( Global temporary storage for the scheduler )
VARIABLE NTASKS  ( Number of runnable tasks  MAX 10)
0 NTASKS !  ( Initialise to zero )
 ( Storage for Level, Priority and Task Address )
: Wakeup ( a1 - )
( Wakeup gets the next task running given the status address )
sleep status W!
wake swap W! pause ;

: SwitchTask 
( Call the scheduler to see who’s next )
sleep status W!
wake status task-> schedulertask W!
pause ;

( Define a general task scheduling process )
NTasks @ dup 0> if ( only execute defined tasks )
0 DO
 I 12 * PTasks + dup LevelAddr ! @ 
 ( Get the address and current level )
 LevelAddr @ 4 + @ ( Get priority setting )
 + dup LevelAddr @ ! ( Save new level )
 100 - dup 0> if ( Modify level if necessary )
 LevelAddr @ !
 LevelAddr @ 8 + @ Wakeup
else drop then pause
again ;
( ------------------------------------------------------ )
.( Clive Maynard’s Forth Environment extract ) cr
.( C.A.Maynard 020488 ) cr

also assembler

code LVALLOT ( n - addr )
( Set up a local buffer. )
( Only callable from a word with local variables )
( UNLK will clean up the stack. )
( USER beware of buffer overflow!!! )
 SUBA.L D0,A7    ( NEW SP )
 MOVE.L A7,-(A6) 
 JMP  (A0)


: #terminator? ( char - f ) 
( check for the terminator of a number: space or CR )
13 of true swap endof
32 of true swap endof
false swap
endcase ;

: PTexpect { buffad nchars | buffadd countup - }
( Fills a buffer but includes Priority Task switching )
buffad 1 + -> buffadd 0 -> countup
nchars 0 do
 ?terminal until 
 key dup emit dup buffadd C! 1 +> buffadd 1 +> countup
 #terminator? if leave then 
countup buffad c! ;

: #IN { | buffaddr - number }
( PC/FORTH intrinsic function!! )
( Collect into a 10 byte buffer and return a number input )
10 lvallot ( set up a local buffer very carefully )
 -> buffaddr
buffaddr 10 PTexpect
buffaddr number? drop ;
( -------------------------------------------------------- )
( A new task building word for Priority Tasks )
( -------------------------------------------------------- )
: PBUILD { TaskAddr | LevelAdr - }
( Initialise conditions for new tasks )
NTasks 10 = abort” Task Priority Table Full. New entry denied”
NTasks @ 12 * PTasks +    ( Get offset into table )
dup -> LevelAdr 0 swap !  ( Set Level to zero )
10 LevelAdr 4 + !  ( Set Priority to default of 10 )
TaskAddr BUILD   ( Now do an ordinary task build )
TaskAddr @ LevelAdr 8 + ! ( Save Status address )
NTasks @ 1+ NTasks ! ( Increase task count )
( ------------------------------------------------------ )
( The Priority Task Definition )
( ------------------------------------------------------ )
: getbuff { | taskno priority - }
( priority reallocation routine)
#in dup .” Task “ . -> taskno cr
taskno NTasks @ < taskno 0> and if 
#in dup 0< if drop 0 then dup .” Priority “ . -> priority 
 ( New priority determined )
 priority 101 < IF
 priority dup 0= if 
 cr .” Zero or negative priority halts the task” cr
 taskno 12 * 4 + PTasks + ! ( Get to storage location )
 ELSE cr .” Priority out of range. No change” cr THEN
else cr .” Task number out of range. No change” cr then ;

: setpriority ( priority allocation task)
taskwindow @ call SetPort
.” Enter the task number followed by” cr .” its desired priority” cr
.” Priorities can be from 0 to 100" cr
 ?terminal if
 getbuff cr then
again ;
( ------------------------------------------------------ )
( The other tasks )
( ------------------------------------------------------ )
 ( Initialise variables )
-7 diff ! 0 angle !
10 rleft W! 20 rtop W!
150 rright W! 160 rbot W! 
( Loop through graphic changes in superb animation )
 rectangle rleft W@ rtop W@ rright W@ rbot W@ call SetRect
 359 angle @ - 0>
 taskwindow @ call SetPort
 angle @ 10 + angle !
 rectangle angle @ 10 call InvertArc
 taskwindow @ call SetPort
 rright W@ diff @ + rright W!
 rbot W@ diff @ + rbot W!
 rright W@ rleft W@ - 5 < if
 7 diff ! then
 rright W@ rleft W@ - 140 > if
 rectangle 0 360 call EraseRect -7 diff ! then
 0 angle !
 SwitchTask ( Get back to the scheduler )
again ;
( -------------------------------------------------------- )
( Initiate the necessary tasking operations )
( -------------------------------------------------------- )
schedulertask build ( slot scheduler into round robin loop )
schedulertask sched
prioritywindow prioritytask Pbuild
prioritytask setpriority
( -------------------------------------------------------- )
.( Define task insertion words to show adding tasks to priority system 
) cr
.( Shrink Mach 2 window to top left corner ) cr
.( Execute  task words: atask, btask and ctask after loading the file 
) cr
.( Change priority through the priority task window ) cr
( -------------------------------------------------------- )
: Atask task1window task1 Pbuild
task1 disks ;

: Btask task2window task2 Pbuild
task2 disks ;

: Ctask task3window task3 Pbuild
task3 disks ;

Community Search:
MacTech Search:

Software Updates via MacUpdate

ffWorks 3.3.5 - A Comprehensive Video Co...
ffWorks, focused on simplicity, brings a fresh approach to the use of FFmpeg, allowing you to create ultra-high-quality movies without the need to write a single line of code on the command-line.... Read more
Arq 7.19.11 - Online backup to Google Dr...
Arq is super-easy online backup for Mac and Windows computers. Back up to your own cloud account (Amazon Cloud Drive, Google Drive, Dropbox, OneDrive, Google Cloud Storage, any S3-compatible server... Read more
Opera 97.0.4719.28 - High-performance We...
Opera is a fast and secure browser trusted by millions of users. With the intuitive interface, Speed Dial and visual bookmarks for organizing favorite sites, news feature with fresh, relevant content... Read more
Google Chrome 111.0.5563.110 - Modern an...
Google Chrome is a Web browser by Google, created to be a modern platform for Web pages and applications. It utilizes very fast loading of Web pages and has a V8 engine, which is a custom built... Read more
Vivaldi 5.7.2921.65 - An advanced browse...
Vivaldi is a browser for our friends. We live in our browsers. Choose one that has the features you need, a style that fits and values you can stand by. From the look and feel, to how you interact... Read more
Ableton Live 11.2.11 - Record music usin...
Ableton Live lets you create and record music on your Mac. Use digital instruments, pre-recorded sounds, and sampled loops to arrange, produce, and perform your music like never before. Ableton Live... Read more
Adobe Acrobat DC 23.001.20093 - Powerful...
Acrobat DC is available only as a part of Adobe Creative Cloud, and can only be installed and/or updated through Adobe's Creative Cloud app. Adobe Acrobat DC DC with Adobe Document Cloud services is... Read more
Adobe Acrobat Reader 23.001.20093 - View...
Adobe Acrobat Reader allows users to view PDF documents. You may not know what a PDF file is, but you've probably come across one at some point. PDF files are used by companies and even the IRS to... Read more
Paragon NTFS 15.10.590 - Provides full r...
Paragon NTFS breaks down the barriers between Windows and macOS. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS. Write, edit, copy, move, delete files on... Read more
Slack 4.31.152 - Collaborative communica...
Slack brings team communication and collaboration into one place so you can get more work done, whether you belong to a large enterprise or a small business. Check off your to-do list and move your... Read more

Latest Forum Discussions

See All

TouchArcade Game of the Week: ‘Well Word...
We were already big fans of developer BJ Malicoat, who does business under the name Bird Cartel, due to the release of Pine Tar Poker late last year. Poker is one of those games that kind of is what it is, so it’s always very hard to come up with... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for March 24th, 2023. It turned out to be a fairly busy one today. We’ve got a little news to look at, plus a review from our pal Mikhail. After that, we get into the many new releases... | Read more »
‘Honkai Star Rail’ Release Date Announce...
Last month, Genshin Impact and Honkai Impact 3rd developer HoYoverse began pre-orders and pre-registrations for the upcoming space fantasy turn-based RPG Honkai Star Rail. | Read more »
Tactical Card Battling RPG ‘Black Book’...
Developer Merteshka and publisher HypeTrain Digital just revealed an iOS version of the card battling tactical RPG Black Book . Black Book is available on PC, Nintendo Switch, Xbox One, and PS4 right now. It will be coming to iOS on April 21st with... | Read more »
Clue/Cluedo: Hasbro’s Mystery Game+ Is T...
Clue: Hasbro’s Mystery Game+ from Marmalade Game Studios is this week’s new Apple Arcade release and it is out now alongside some notable updates. Clue: Hasbro’s Mystery Game+ or Cluedo: Hasbro’s Mystery Game+ depending on your region joins the... | Read more »
‘Stakes Winner ACA NEOGEO’ Review – A Ho...
When it comes to the NEOGEO, a few genres come to mind. Fighting games. Side-scrolling action games. Maybe shooters and beat-em-ups. The usual array of sports. You probably don’t think of horse racing games, but this was an arcade platform that was... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for March 23rd, 2023. In today’s article, we kick things off with a couple of reviews. I take a look at Playism and kouri’s Ib, while our pal Mikhail has a look at the latest DLC... | Read more »
Snowbreak: Containment Zone is the lates...
Mobile gaming enthusiasts will soon be able to get their fill of sci-fi shooting, with Amazing Season announcing their upcoming game, Snowbreak: Containment Zone. Pre-registrations are now open for fans, and we also have their first trailer to get... | Read more »
Square Enix’s Card RPGs Voice of Cards:...
Back in late 2021, Square Enix released a new card-based RPG Voice of Cards: The Isle Dragon Roars on PS4, Nintendo Switch, and PC featuring some of the staff behind the NieR and Drakengard games. This included Yoko Taro, Yosuke Saito, Keiichi Okabe... | Read more »
Out Now: ‘Mighty DOOM’, ‘Down in Bermuda...
Each and every day new mobile games are hitting the App Store, and so each week we put together a big old list of all the best new releases of the past seven days. Back in the day the App Store would showcase the same games for a week, and then... | Read more »

Price Scanner via

Shop our Apple MacBook Price Trackers for the...
We’ve updated our Apple award-winning MacBook Price Trackers with the latest information on prices, bundles, and availability for 16″, 14″, and 13″ MacBook Pros along with 13″ MacBook Airs from Apple... Read more
Back in stock: M1-powered Mac minis for only...
Apple has restocked clearance M1-powered Mac minis in their Certified Refurbished section starting at only $469. Each mini comes with Apple’s one-year warranty, and shipping is free. The following... Read more
Apple to release updated AirPods Pro 2 with U...
Analyst Ming-Chi Kuo, in his latest post, suggests that Apple will soon release an updated version of AirPods Pro 2 with a new USB-C case, replacing the current case using an Apple Lightning... Read more
16″ M2 Pro MacBook Pros on sale for $150 off...
Apple retailer Expercom has 16″ M2 Pro MacBook Pros in stock today and on sale for $150 off MSRP, valid through March 28, 2023. In addition to their MacBook Pro sale prices, take $50 off AppleCare+... Read more
13-inch M2 MacBook Pros on sale for $100 off...
Expercom has 13″ MacBook Pros with Apple M2 processors in stock and on sale today for $100 off MSRP through March 28, 2023. Shipping is free: – 2022 13″ MacBook Pro M2 CPU/256GB SSD: $1199, save $100... Read more
Amazon is selling Apple’s 24″ M1 iMacs for $2...
Amazon has Apple’s 24″ M1 iMacs on sale for $200 off MSRP. Their prices are currently the lowest available for new iMacs among the Apple retailers we track: – 24″ M1 iMacs (8-Core CPU/7-Core GPU/... Read more
Apple’s 10th-generation 10.2″ iPads are on sa...
Amazon has Apple’s 10th-generation iPads on sale for $50 off MSRP starting at only $399. Their discount applies to all models and all colors. With the discount, Amazon’s prices are the lowest... Read more
Apple 13-inch MacBook Pros are on sale for $1...
Amazon has 13″ MacBook Pros with Apple M2 processors in stock and on sale today for $150 off MSRP. Their prices are the lowest currently available these MacBook Pros. Be sure to purchase from Amazon... Read more
Apple Pro Display XDR with Nano-Texture Glass...
Apple Authorized Retailer Adorama has the Pro Display XDR with Nano-Texture Glass on sale for $500 off MSRP today. Shipping is free: – Apple 27″ Pro Display XDR Nano-Texture Glass: $5499 $500 off... Read more
10-Core M1 Max Apple Mac Studio on sale for $...
Adorama has the base 10-Core M1 Max Mac Studio in stock and on sale today for $1799 including free shipping. Their price is $200 off Apple’s MSRP, and it’s the lowest price available for a new Mac... Read more

Jobs Board

Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States ( - Apple Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States ( - Apple Blossom Read more
Beauty Consultant - *Apple* Blossom Mall -...
Beauty Consultant - Apple Blossom Mall Location:Winchester, VA, United States ( - Apple Read more
Sales Floor Associate - *Apple* Blossom Mal...
Sales Floor Associate - Apple Blossom Mall Location:Winchester, VA, United States ( - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States ( - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.