[comp.sys.mac.hypercard] Hypercard & LSC C 3.0

wb1j+@andrew.cmu.edu (William M. Bumgarner) (10/19/88)

I'm writing several XCMD's that require using 'SendCardMessage'.  I have
modelled the call after the format in Gary Bond's book (MySendCardMessage and
ToPStr).  Everytime the XCMD excutes a SendCardMessage (even 'go next card'),
hypercard beeps and terminates execution of the XCMD...

Any help, code samples, complete projects would be appreciated.

Thanks to all who sent the first set of examples, notes, etc... they helped
a lot.  None of them contained calls back to hypercard...

b.bum
wb1j+@andrew.cmu.edu

kurtzman@pollux.usc.edu (Stephen Kurtzman) (10/20/88)

In article <gXL0Udt38k-0M=HVhr@andrew.cmu.edu> wb1j+@andrew.cmu.edu (William M. Bumgarner) writes:
>I'm writing several XCMD's that require using 'SendCardMessage'.  I have
>modelled the call after the format in Gary Bond's book (MySendCardMessage and
>ToPStr).  Everytime the XCMD excutes a SendCardMessage (even 'go next card'),
>hypercard beeps and terminates execution of the XCMD...

you are probably using a string constant. lsc changed the way it generated
code resources between 2.15 and 3.0. Read the section entitled "Global data in
code resources" on pages 84&85 in the lsc 3.0 User's manual. you will probably
find that you need to save, setup, and restore R4 as demonstrated in this
section. Good luck.

beard@ux1.lbl.gov (Patrick C Beard) (10/21/88)

And, here is the example code for how to set up A4 from withing an XCMD:

----<cut here>----
/* ExampleXCMD.c -- bare minimum LSC 3.0 XCMD */
#include <SetUpA4.h>	/* for global access */
#include "HyperXCmd.h"

/* globals */
Handle returnValue=nil;	/* set this if something is to be returned */

#define OpenGlobals() 	RememberA0(); SetUpA4();
#define CloseGlobals()	RestoreA4();

/* entry point */
pascal void main(paramPtr)
	XCmdBlockPtr	paramPtr;
{	
	OpenGlobals();

	/* we now have access to our globals! */
	DoXCMD(paramPtr);	/* whatever this XCMD does */
	
	/* check to see if we should return any value */
	if(returnValue)
		paramPtr->returnValue=returnValue;

	CloseGlobals();
}

----<end of file>----

I hope this helps.

Patrick Beard
Lawrence Berkeley Laboratory
beard@ux1.lbl.gov