Aug 92 Mousehole
Volume Number: | | 8
|
Issue Number: | | 4
|
Column Tag: | | Mousehole
|
Mousehole ![](img001.gif)
By Larry Nedry, MacTutor Regular Contributing Author
From: Derek
To: ** ALL **
Re: Programming for System 7
I am having some problems trying the code from the book Programming System 7 to work with my THINK C compiler version 4.05. I keep this error: Illegal Function Prototype. (I think it has to do with some System 7 specific toolbox routines?)
I havent programmed in a few years and I admit I am a bit rusty with C and the Mac.
Any help that does not include buying an upgrade for my THINK C compiler would be greatly appreciated. (Ive bought upgrades for all for THINK Pascal and THINK C in the past, but with this recession I admit I am broke currently)
Thanx in advance
From: Tims
To: Derek
Re: Programming for System 7
Derek - I co-authored Programming for System 7 and all of the sample C source in it relies on Think C v.5.x. If youre still using pre-5.x, then youre lacking all of the System 7 interfaces and Programming for System 7 uses a lot of different System 7 calls. There were also some changes in THINK itself from 4.x to 5.x (I believe 5.x is when they started using Apples interfaces so the code can be easily moved between MPW C and THINK C).
The cleanest solution is to upgrade to THINK C v.5.x (I know, $$$$s tight, but youre going to spend a LOT more time and effort creating your own System 7 interfaces and tweaking our code to work under 4.0 than you might imagine). Bear in mind that the listings in the book are not the full thing (theres some behind the scenes housekeeping stuff for publish/subscribe, comm toolbox, balloon help, and the desktop database thats not listed in the book, but is on the disk [see the coupon inside the back cover of the book...]). If you did go to all the trouble of tweaking the listings to work under THINK C 4.x, youd have to either write your own behind the scenes stuff or get the disk and convert that source as well (a fairly major task and not one Id recommend to anybody). Thats why I say that despite the cost of moving to THINK C 5.x, youll come out ahead in the long run.
Hope that helps at least a little.
From: Derek
To: Tims
Re: Programming for System 7
Thank you for the advice. I did buy an upgrade and the disk. (my spouse is out of work, not myself!) I hate to ask such a simple question, but I am getting an error and I can not figure out why.
I get this same error with the code I typed in or from the disk I purchased so I assume it must be my THINK C setup somehow.
pascal OSErr HandleOAPP( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon );
On the above line I get a syntax error The place in the line it stops with the error is when it gets to the: *theAppleEvent.
Sorry to keep asking simple problems but if anyone could help me with this I would really appreciate it.
From: Tims
To: Derek
Re: Programming for System 7
Welcome to THINKs idea of System 7 support <grin>.
The problem youre encountering is that THINKs std out-of-the-box MacHeaders file doesnt bother to include any of the System 7 specific interfaces. You have to include them yourself or edit the Mac #include.c file and re-precompile it (to recreate a more meaningful MacHeaders file).
The disk for the book was supposed to address that problem by using a custom pre-compiled header. Did you open the PROJECT that came with the disk or did you just bring the source files into your existing project?
The Read Me should have some info on the whole situation, but may not (I havent read the Read Me since late last year when Gary and I wrote it <grin>).
Hope that helps.
From: Derek
To: Tims
Re: Programming for System 7
Thank you very much for the help. I did include the necessary System 7 headers and now everything works fine.
From: Markspace
To: Tims
Re: C++? (1 reply)
About the only thing I find myself wanting to use under THINK C from C++ is multiple inheritance.
From: Tims
To: Markspace
Re: C++?
I sat in on some heavy arguments on whether or not multiple inheritance was a useful feature or a crutch. The folks referring to it as a crutch claimed that any example you could give them of when MI was needed, they could show it could be done without MI, thus MI was merely a crutch that let you avoid doing your class hierarchy correctly. I never did completely agree with either side, but it seems to me that any language feature that can bail you out late in a project, even if it is a crutch is a heck of a lot more practical than rewriting your class hierarchy from scratch. Somehow the crutch crowd didnt always seem to see the practical side of a development tool, preferring to stick to the academic side.
Just a few thoughts from days gone by.
Tim (my opinions are my own and Im not a super-expert on C++) S.
From: Halldor
To: ** ALL **
Re: DAs and access to selected text in applications
Hello. I am new to Mac programming and, I am writing a program that has to take the text selected in a word processor, modify it and turn it back to the word processor. Is there any reasonable way of doing this on the Mac? Is there any book around that describes DA programming in detail, other than IM, do you know of any DA source code in your library? Thanks for reading this message, a response would be appreciated, if not... thanks anyway!!
From: Mrteague
To: Halldor
Re: DAs and access to selected text in applications
Although you are new to Mac programming, can you tell me if you intend using the code you mention for something more than an example? The reason I ask, if you want to jump in at the deep end, and have an application that would require System 7.0.x, then you might want to consider using AppleEvents - your example would be an ideal use of AppleEvents, especially considering the Word Services AppleEvent Registry is almost complete, and this registry is designed for the very thing you ask. However I will assume for the moment that you dont want something so difficult to start with <grin> - you shouldnt need to even worry about writing a DA (especially since System 7.0.x discourages such things), since standard applications that use the Clipboard correctly will work as you intend without a DA. Suggest you get a hold of the standard Apple example source code (it comes with MPW, and may be available separately, maybe even from here). The important things to remember are: handle resume/suspend events if running under MultiFinder/ System 7.0.x (and set the appropriate bits in the SIZE resource - you can get away with not doing this, but MultiFinder(?) Process Manager will fake Clipboard copy/paste like a DA and it will be a little slower than you doing it); and convert between any private scrap you may have and the public scrap (Clipboard). The operating System will take care of updating the Clipboard in both applications, if both you and the other application do the correct thing. HOWEVER, none of this (and DAs without a lot of work) will help your application REPLACE the selected text in the word-processing application - to do this usually requires some kind of INIT, and lots of horrible behind the scenes fiddling with TextEdit (and wont work with all applications) - I liken your example to a Spelling Checker, and Im sure other people will tell you what kinds of lengths Spelling Checkers go to, to work with applications. Hope this helps.
From: Halldor
To: Mrteague
Re: DAs and access to selected text in applications
Thanks this helps a lot, I was hoping that there was a quick (and maybe dirty) way of doing this. The reason for all this is that English is my second language, (Icelandic being the first one) and Ive written a translation program that does a lot of the dictionary flipping for me. I wanted to see if there was an easy way of extending the program to communicate with applications. Thanks for the help, Ill turn to 7.0.x for completing the task.
From: Sysop
To: Dizzy
Re: Quadra 900
My Quadra seems to be faster for everything I do. It is faster for hard disk usage, network and running applications. I have run into a few apps that will not run with the 040 caches turned on but that is easy to fix with a cdev called Compatible. It turns the cache off when selected apps are run. Even QuickTime movies are much smoother.
From: Sysop
To: ** ALL **
Re: Quadra 900 with OverDrive
I just purchased an OverDrive kit from Newer Technology. It is a small card that plugs into the ROM socket on the Quadra 900 that speeds up the CPU to 33 MHz. It was fairly easy to install and my Quadra is now running 32% faster. It is definitely noticeable. I love it!
I ran Speedometer 3.06 before and after. The results are:
Before After
CPU 16 22
Graphics 19 25
Disk 4 4
Math 102 136
These results show how much faster this machine is with the OverDrive kit.