Scripting Additions Guide

CHAPTER 3
Writing Scripting Additions
Sample Scripting Addition 95
////////////////////////////////////////////////////////////////////
//
// PlaySndEntry ()
//
// The direct parameter is either a name or an ID of the 'snd '
// resource to play.
//
//////////////////////////////////////////////////////////////////
pascal OSErr PlaySndEntry( AppleEvent *theAEEvent,
AppleEvent *theReply,
long theRefCon)
{
/* Function Prototypes */
OSErr PlaySound(Handle theSoundHdl);
/* variables */
OSErr theErr = noErr;
DescType typeCode;
Size sizeOfParam,
actualSize;
Handle theSndHandle = nil; /*just clear our */
/* sound handle*/
SndChannelPtr theSndChan = NULL; /*NULL pointer to */
/* a sound channel*/
short ourRezID = 0;
Str255 ourRezName;
FSSpec ourSoundFile;
short ourFileRef, curResFile;
/*
Get the data type from direct object by using AESizeOfParam.
We use this call instead of AEGetParamDesc or AEGetParamPtr
because we are looking for one of several types. In this