[Note: This is very long. It's useful information so I'll abuse the privilege just this once and post it anyway. If you don't want to read this, you might want to hit for scroll at the next prompt and go get a beverage.] These, as promised, are the details in the conversion of the DTS sample program Lister to compile and run under ORCA/C. The entire conversion process was not entirely simple because of a few differences in compiler architecture and code design, but the guide to changes here should help you in converting the rest of the DTS samples, and perhaps any APW C program, to run under ORCA/C. There were problems in the conversion that were due both to programming style and problems with ORCA/C. It should be noted, however, that C and ORCA/C are flexible enough to overcome the problems with a minimum of difficulty, and that Mike Westerfield's response time to fixing a few library problems was quite impressive. That aside, let's get to the meat. First of all, you need fmd.h from "DTS Tools and Libs" in the same folder as the Lister source (and lister.h). Once that's done, you'll find fmd.h won't compile. fmd.h is full of declarations for the FakeModalDialog tool that look like this: #ifdef __fmdTool__ #define fmdToolNum 1 #ifndef userDispatch #define userDispatch 0xE10008 #endif extern pascal void fmdStartUp() inline(fmdToolNum+0x0200,userDispatch); etc. ORCA/C 1.1 has a limitation - it wants the first parameter to the inline function to be an integer and it will not accept expressions in this field. So, fmd.h must be converted to contain lines like this: extern pascal void fmdStartUp() inline(0x0201,userDispatch); Note that if you ever use the FakeModalDialog tool with a number other than one, you'll have to change this file. ORCA/C can use the library version of FakeModalDialog and you might find that easier to work with; Lister uses the user tool set version because it's a little trickier and therefore DTS chose to demonstrate how to do it. Next, you'll find some troublesome code in the start.c file: if (!_toolErr) fmdInfo = Restart(tempID); if (_toolErr) fmdInfo = InitialLoad(0x1000, fmdName, 0); if (err = _toolErr) { InitCursor(); TLMountVolume(40, 32, "\pYou need fakeModalTool in same", "\pfolder as lister.", "\pAgain", "\pCome"); _toolErr = err; } else SetTSPtr(userTool, fmdToolNum, fmdInfo.startAddr); #endif The line with the Restart on it will not compile - Restart is declared as returning a RestartOutRec and fmdInfo is declared as taking an InitialLoadOutputRec. APW C allows them to be interchanged since the records are identical - ORCA/C (and I believe ANSI C) don't allow this. I made a change in my Loader.h file because I think I'll often want to use the same record for both Restart and InitialLoad: struct InitialLoadOutputRec { Word userID; /* */ Pointer startAddr; /* */ Word dPageAddr; /* */ Word buffSize; /* */ } ; typedef struct InitialLoadOutputRec InitialLoadOutputRec, *InitialLoadOutputRecPtr; typedef struct InitialLoadOutputRec RestartOutRec, *RestartOutRecPtr; #if 0 struct RestartOutRec { Word userID; /* */ Pointer startAddr; /* */ Word dPageAddr; /* */ Word buffSize; /* */ } ; typedef struct RestartOutRec RestartOutRec, *RestartOutRecPtr; #endif After these changes, the program will compile but not run. There are a few reasons for this. First, APW C and ORCA/C treat tool errors differently. APW C uses a global int variable called _toolErr and ORCA/C uses an int function called toolerror(). Since in most cases these are exactly the same, I avoided a lot of editing of Lister by adding the following to near the beginning of my types.h file: #ifdef __ORCAC__ #define _toolErr toolerror() #endif This causes the preprocessor to replace all instances of _toolErr with toolerror(), which normally works. There is one exception in Lister, which is in the troublesome code posted above: _toolErr = err; This expands to: toolerror() = err; and you can't assign a value (an r-value) to toolerror (not an l-value). Most of Lister depends on _toolErr (or toolerror()) being clear, so to avoid a lot of rewriting I wrote a small assembly procedure I call "settoolerror". All this routine does is set the value returned by toolerror() (global symbol value ~TOOLERROR). The source and macros for this are included so you can assemble it and include it. So with changes, the troublesome code above looks like this: [near the top of the file] void doFmdStartUp(); void doFmdShutDown(); void settoolerror(unsigned int); [in doFmdStartUp()] if (err = _toolErr) { InitCursor(); TLMountVolume(40, 32, "\pYou need fakeModalTool in same", "\pfolder as lister.", "\pAgain", "\pCome"); settoolerror(err); } else SetTSPtr(userTool, fmdToolNum, fmdInfo.startAddr); With this done, the program still won't run. The remainder of the problems are in the ORCA/C library itself. Mike and I have prepared a fix for these bugs, which has been uploaded as ORCALIB.BXY (it's not a new ORCALIB, but that way it will grab the attention of people who need it). The changes are detailed in that file, which includes a new library file, source and a READ.ME file. Briefly, the glue for Restart in the ORCA/C 1.1 library is incorrect and crashes, and tool calls with glue aren't correctly storing into ~TOOLERROR. The new library corrects these problems. This message is included with ORCADTS.BXY, a file that includes all the changes necessary to make Lister work under ORCA/C. It also includes a 360 Microsystems MAKEFILE for their MAKE utility, which I think is marvelous. I think a good make utility can save lots and lots of time when programming, and this is the one I use. The makefile uses Zaplink instead of LinkIIgs, since LinkIIgs is demonstrated with Lister's normal build script. I used the .dfork and .rfork model because it's easier for me to follow -- both Zaplink and Rez leave the fork they don't use totally intact, so in reality the intermediate .fork files aren't necessary. Matt Deatherage Developer Technical Support Apple Computer, Inc.