Scripting Additions Guide

CHAPTER 3
Writing Scripting Additions
Sample Scripting Addition 99
/* check the error */
theErr = ResError();
if(theErr != noErr)
return theErr;
/* make our files resource fork top in the chain */
UseResFile(ourFileRef);
/*
Since we don't know for sure the resource id of
the targeted files 'snd ' resource, let's just
get the first (and supposedly only) one.
*/
theSndHandle = Get1IndResource(kSndType, 1);
/* check the error */
theErr = ResError();
if(theErr == noErr)
theErr = PlaySound(theSndHandle);
/* restore resource chain and close our file */
UseResFile(curResFile);
CloseResFile(ourFileRef);
}
else /* wasn't a string, alias, or number so exit */
return errAEEventNotHandled;
}
}
}
/* dispose 'snd ' handle if necessary */
if(theSndHandle != nil) ReleaseResource(theSndHandle);
return theErr;
}