Important: The information in this document is obsolete and should not be used for new development.
Supplying an Alternative Active Function
Every scripting component calls an active function periodically during script compilation and execution. All scripting components support routines that allow your application to set or get the pointer to the active function used by that scripting component.
TYPE OSAActiveProcPtr = ProcPtr;A pointer of typeOSAActiveProcPtr
points to aMyActiveProc
function that takes a reference constant as a parameter.
FUNCTION MyActiveProc(refCon: LongInt): OSErr;If you want your application to get time periodically during script compilation and execution for tasks such as spinning the cursor or checking for system-level errors, you should provide an alternative active function that performs those tasks. To set an alternative active function, callOSASetActiveProc
; to get the current active function, callOSAGetActiveProc
.If you do not set an alternative active function for a scripting component, it uses its own default active function. A scripting component's default active function allows a user to cancel script execution by pressing Command-period and calls
WaitNextEvent
to give other processes time.Your alternative active function can in turn call the scripting component's default active function. To do this, your application can call
OSAGetActiveProc
before callingOSASetActiveProc
to set the alternative active function, then call the default active function directly when necessary. Some scripting components may also supply building-block routines that your application can use to construct an alternative active function.Multithreaded applications may need to give time to other threads while one thread is waiting for the scripting component to complete compilation or execution of a script. You can provide an alternative send function and an idle function that allows threads to be switched (see "Alternative Send Functions" on page 10-25). However, the Apple Event Manager calls an idle function only after an Apple event has been sent, whereas a scripting component calls an active function at regular intervals throughout script compilation and execution. Thus, to give time to multiple threads, you may want to provide an alternative active function in addition to an alternative send function and an idle function.
When a scripting component calls your alternative active function, the A5 register is set up for your application, and your application is the current process.