Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
OSAExecuteEvent help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OSAExecuteEvent help



I've been trying to implement use of OSAExecuteEvent in my application.
There was a previous posting Chris Espinosa which has some source code
which I've based my code upon. I'm just calling a subroutine, not an
event defined in the 'aete' resource. The problem I am having is I
always get errAEEventNotHandled. I have created a routine that when
passed a string, and parameters, will call OSAExecuteEvent for the
subroutine specified in the string, with the passed in parameters. I'm
pretty sure there is no problem with the creating the scripting
component, or loading the script as I can use OSAExecute without any
problems. Here is my routine: ...

//
---------------------------------------------------------------------------

// * ExecuteEvent [public]
//
---------------------------------------------------------------------------

// Runs the script
void
CAppleScript::ExecuteEvent(
const LStr255& inSubroutine,
const AEDesc& inParameters)
{
sLastErrorStr[0] = mErrorStr[0] = 0;
sLastError = mExecuteError = noErr;

if (mResultID)
{
::OSADispose(mScriptingComponent, mResultID);
mResultID = 0;
}


AppleEvent theEvent;

UAppleEventsMgr::MakeAppleEvent(kASAppleScriptSuite,kASSubroutineEvent,theEv

ent);


ThrowIfOSErr_(::AEPutParamPtr(&theEvent,keyASSubroutineName,typeChar,inSubro

utine.ConstTextPtr(),inSubroutine.Length()));

ThrowIfOSErr_(::AEPutParamDesc(&theEvent,keyDirectObject,&inParameters));


OSErr result = ::OSAExecuteEvent(mScriptingComponent, &theEvent,
mScriptID, mCompileExecuteMode, &mResultID);


::AEDisposeDesc(&theEvent);


if (result)
GetAppleScriptError();


ThrowIfOSErr_(result);
}

where inEvent is the string parameter with the sub's name, inParameters
is an AEList with the parameters. The rest of the variables are
hopefully self explanatory. For my testing I'm just using a subroutine
that has no parameters, so the list is empty. The script itself looks
like:
on mySubroutine()
....
end mySubroutine

I also went ahead and created an event in my 'aete' resource, and
created the AppleEvent with its suite and event code, and modified the
script appropriately and I still got the same error.

Any ideas as to what I'm missing or doing wrong?
Thanks,
Micah




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.