[net.sources.mac] A program and a flame. . .

tdn@spice.cs.cmu.edu (Thomas Newton) (11/10/85)

A while back, someone posted a desk accessory sampler program which was called
"Whitman's 'Desk Accessory' Sampler" to the net.  This program was distributed
as shareware, with a fee of $10.  My first reaction upon using the program was
that it performed a useful function but that it must have been utterly trivial
to write, given the Mac's support for resources (such as desk accessories...).
Thus, I stopped using the program (rather than forking over $10 or using it on
a regular basis without paying for it), and resolved to write and give away my
own program to do the same thing.

On Friday night, I decided to kill some time, so I sat down at my Mac with my
copies of Megamax C v2.1, Inside Mac, and SKEL 2.2.3C.  By the time that I was
ready to go to sleep, I had the program working with the exception that (a) it
didn't do anything in response to the "About..." menu item, and (b) it didn't
have a special icon.  A lot of the time that I spent on it was occupied by one
of two tasks:  (a) cutting things out of SKEL that my program didn't need, and
(b) replacing "#include" statements with selected definitions from the Megamax
header files (I have a 128K Mac, and MMC 2.1b tends to run out of symbol table
space on 128K Macs for programs that have lots of "#include" statements).  As
of some time tonight, I finished up the task of making an "About..." dialog
box and a special icon for the program and was finished.

The advantages that my Desk Accessory Sampler has over the other version are:

    1.  It's free.  You don't need to make a choice between giving up
        $10 or giving up the use of the program in order to be honest.
    2.  It comes with source code.  If you think that it could use any
        changes, you can hack on it to your heart's content.
    3.  It changes the highlighting status of the "Close" menu item to
        let you know whether or not you currently have a resource file
        open (the shareware program doesn't give any such indication).
        (Note: as in the other program, "Open" can be selected while a
        resource file is open; in this case, the program closes the old
        resource file before opening the new one.)
    4.  It provides all five of the standard editing commands (UNDO, CUT,
        COPY, PASTE, CLEAR) in the EDIT menu, as opposed to the three
        (CUT, COPY, PASTE) supported by the shareware program.  Note: I
        was really amazed to see this -- setting up a menu with all five
	commands is *very* easy (as in "editing cmd # = menu item #-1").
    5.  It attempts to avoid situations of the type "there is an accessory
        running whose resource file we have just closed" since these lead
        directly to system crashes.  Unfortunately, I don't know of a good
        way to keep track of which accessories are active (while OpenDeskAcc
        returns a reference number if it succeeds, it may return garbage if
        it fails).  The approach that my program takes, therefore, is to try
	to close every driver with a resource ID between 12 and 31; this seems
        to work fairly well.  It certainly works better than the approach of
        doing nothing and letting the system crash and burn. . .
    6.  It has a toggle switch in the FILE menu that allows you to open *any*
        Macintosh file and use its "DRVR" resources.  This isn't a very major
        feature; on the other hand, it wasn't hard to put in . . .

It's bad enough that someone is trying to collect money for a program that
is obviously doing very trivial things.  What's even worse is that it isn't
even very competent at what it does do!!!  Is it too much to ask that people
refrain from marking every hack they throw together as shareware requiring a
donation for continued use?

Anyway, I'm posting both the program's source form (Sampler.c, Sampler.R)
and its binary form (Sampler.Hqx) to net.sources.mac.  Enjoy.

                                        -- Thomas Newton
                                           Thomas.Newton@spice.cs.cmu.edu

brianb@3comvax.UUCP (Brian Bechtel) (11/12/85)

>The approach that my program takes, therefore, is to try
>to close every driver with a resource ID between 12 and 31; this seems
>to work fairly well.  It certainly works better than the approach of
>doing nothing and letting the system crash and burn. . .

Sorry.  Apple changed the rules.  In a document distributed with the May
1985 software supplement, titled "Life After Font/DA Mover -- How To
Make Sure Your Desk Accessory Still Works" you find the lines:
----------
By the Way... Before the Font/DA Mover, desk accessories could have an
ID in the range 12 to 31.  Now, and in the future, desk accessories can
only have IDs in the range 12 to 26.  The Font/DA Mover will only
assign numbers in this range.  Numbers 27 thru 31 are reserved for
dynamic allocation of IDs at runtime for disk drivers, mail servers,
etc.
----------
EtherMac is such a product.  Sampler will close our Appletalk/Ethernet
driver, which is disasterous if you're running from the network. The
only way to recover is to reboot.  The close code should look like:

CloseAllAccs()
{
    int i;
    for (i = 12; i < 27; i++) CloseDeskAcc(-i-1);
}

and everything will be fine.

--Brian Bechtel		{apple, bnrmtv, oliveb}!3comvax!brianb

vishniac@wanginst.UUCP (Ephraim Vishniac) (11/21/85)

> Sorry.  Apple changed the rules.  In a document distributed with the May
> 1985 software supplement, titled "Life After Font/DA Mover -- How To
> Make Sure Your Desk Accessory Still Works" you find the lines:
> ----------
> By the Way... Before the Font/DA Mover, desk accessories could have an
> ID in the range 12 to 31.  Now, and in the future, desk accessories can
> only have IDs in the range 12 to 26.  The Font/DA Mover will only
> assign numbers in this range.  Numbers 27 thru 31 are reserved for
> dynamic allocation of IDs at runtime for disk drivers, mail servers,
> etc.
> ----------
> EtherMac is such a product.  Sampler will close our Appletalk/Ethernet
> driver, which is disasterous if you're running from the network. The
> only way to recover is to reboot.  The close code should look like:
> 
> ...

But more interesting is the question, "What does the code for dynamic
driver ID allocation look like?"  Am I guessing correctly that one would
store the driver with a bogus ID (i.e., >31), then at runtime load it
(_GetResource), detach it, find a free ID, do an _AddResource with the
free ID, then open it with the new ID?

-- 
Ephraim Vishniac
  [apollo, bbncca, cadmus, decvax, harvard, linus, masscomp]!wanginst!vishniac
  vishniac%Wang-Inst@Csnet-Relay