[comp.sys.mac.programmer] DA question

bolter@unc.cs.unc.edu (Jay D. Bolter) (05/31/88)

Can anyone suggest how to create a Desk Accessory with a large 
amount of code (say 70 or 80K)? What are the factors that limit 
you to 32K? Is it possible, for example, to store more code in one's 
own resources (in addition to the DRVR resource) and then call in 
that code as needed. If so, how do you pass control to and from these 
code resources? Can anyone suggest any books or articles that discuss 
problems of large DAs? (I am programming in MPW Pascal.)

dan@Apple.COM (Dan Allen) (06/01/88)

About DAs of the 70K size, written in MPW Pascal...

DAs do not have their own A5 World, ordinarily.  This means no global
data, no jump data (no code segments), and no own QuickDraw globals,
among other things.

If a desk accessory can save and restore A5 then these problems would go
away.  As I have mentioned in this forum previously, this was actually
under consideration here at Apple, but had problems.

The party line today is to not write DAs that big: just write an
application which **does** have its own A5 World, and use MultiFinder!

If this very simple solution to the problem (or sidestepping of the
problem) is not adequate, please tell me more.  We'd like to do what we
can in solving developer's problems.

Dan Allen
Software Explorer
Apple Computer

leonardr@uxe.cso.uiuc.edu (06/01/88)

bolter@unc.cs.unc.edu(??) writes in comp.sys.mac.programmer


>Can anyone suggest how to create a Desk Accessory with a large 
>amount of code (say 70 or 80K)? What are the factors that limit 
>you to 32K? Is it possible, for example, to store more code in one's 
>own resources (in addition to the DRVR resource) and then call in 
>that code as needed. If so, how do you pass control to and from these 
>code resources? Can anyone suggest any books or articles that discuss 
>problems of large DAs? (I am programming in MPW Pascal.)

	It is possible to creeate DA's which are larger thatn the 32K limit that
is imposed by the size of resources (of which the DRVR is one).  This is 
apparent when you try to install such DA's as DiskTop or DiskTools.
	The reason taht you are 'normamly' limited to 32K is that DRVR resourcw which
contains your code is limited to 32K. To get around this problems (as I have 
recently in SigmaEdit) what you must do is to use the DRVR for your main code
and any code that uses a LOT of globals and put all thre rest of your code in
other code type resources.  I use PROC's, but it does not matter as long as they
are compiled as code resources.  You then just load these up as need be and
call them.  What you need to do is to simulate the _LoadSeg trap.  Rich Siegel
(our local Think rep) gave an example of doing this from LSP, and the same would
how true for MPW Pascal.
	The only place that I have seen this discussed was in an old article by
David Dunham in MacTutor (I believe that it is reprinted in Best of Mac Tutor
Volume I)
	Hope this helps...

+---------------------------------+-----------------------------------+
+                                 +  Any thing I say may be taken as  +
+   Leonard Rosenthol             +  fact, then again you might decide+
+   President, LazerWare, inc.    +  that it really isn't, so you     +
+                                 +  never know, do you??             +
+   leonardr@uxe.cso.uiuc.edu     +                                   +
+   GEnie:  MACgician             +                                   +
+   Delphi: MACgician             +                                   +
+                                 +                                   +
+---------------------------------+-----------------------------------+

isle@eleazar.dartmouth.edu (Ken Hancock) (08/09/89)

I ran into an interesting problem the other day while
debugging a desk accessory.  The DA seemed to work fine,
except for when another DA was opened and became frontmost
and was then closed.  My DA almost always bombed immediately
after the other DA was closed.

What I found was that when my DA was shifted to the back,
the DRVR was unlocked, causing it to be relocated.  My
DA's main window is brought up with the Dialog Manager
and has a number of user items.  So, when the DRVR
was moved, all the pointers to update procs stored in
the user items' handles were invalidated.

Simple enough solution is to just reinitialize the
user items before any activate event.  What I found
hard to believe is that I couldn't find this unlocking
of the DRVR ANYWHERE -- it seemed to me a fairly common
problem and I was surprised that it wasn't in a Technote.

Someone please tell me that I just missed something and
that it is documented.  And if it's not, might DTS
want to document this in a technote somewhere???

Ken


Ken Hancock  '90                    | E-mail: (BITNET/UUCP/INTERNET)
Computer Resource Center Consultant |   isle@eleazar.dartmouth.edu
------------------------------------+---------------------------------------
DISCLAIMER?  I don't get paid enough to worry about disclaimers.