[fa.info-mac] Getting desk accy's to work with Sumacc

info-mac@uw-beaver (info-mac) (11/19/84)

From: John W. Peterson <JW-Peterson@UTAH-20.ARPA>
The problems with using Sumacc desk accessories with Sumacc programs is
related to the "leading null" convention used for desk accessory names.  In
order to read desk accessory menu items, some special coding (e.g., the 
DAname routine in the Sumacc example programs) is used so the leading zero
in the names doesn't get fouled up by C using null as a string terminator.
However, a side effect of this coding is the leading null -must- be there
in order for a Sumacc program to find the accessory.

Unfortunatly, the desk installation program supplied with Calendar doesn't
add the leading zero when it installs the name.  Thus Pascal or assembly
language applications which don't care about leading nulls in strings
(e.g., the finder) work fine, but Sumacc programs don't.  I've used the
following kludge in desk.c to get around the problem:

   char deskname[256];
   char *c2pnstr();
   extern char *isapstr();
   char *desknameconst = "xxCalendar";

   /* KLUDGE needed to get it installed right... */
   strcpy(deskname, desknameconst);
   deskname[0] = (char) 9;  /* Pascal string len */
   deskname[1] = '\0';      /* the funny null for DA names */

This is used later on like:

         AddResource(handle, "DRVR", id, isapstr(deskname));

The "isapstr" tells the Sumacc toolbox interface that the argument is
already a Pascal string and doesn't need to be converted.
-------