Initiates a time delayed function call. When the calling date falls, the call is automatically realized by MidiShare under interrupt. MidiCall is presented here for historical reasons, and MidiTask is a better choice of code for completing this task.
pascal void MidiCall (TaskPtr MyProc, long date, short refNum, long a1, long a2, long a3);
MyProc
- a TaskPtr, is the address of the function to be called.
date
- a 32-bit integer, is the date at which this call is scheduled.
refNum
- a 16-bit integer, it is the reference number of the application.
a1,a2,a3
- are 32-bit integers left at the user's disposal, as arguments of MyProc.
pascal void MyProc (long date, short refNum, long a1, long a2, long a3);
date
- a 32-bit integer, is the date of the call .
refNum
- a 16-bit integer, is the reference number of the application.
a1,a2,a3
- are 32-bit integers that can be used by the application.
Send periodically (every 10 ms), a MidiClock message for 30 seconds.
void MyClock (long date, short refNum, long delay, long limit, long a3) { if (date < limit) { MidiSendIm (refNum, MidiNewEv(typeClock)); MidiCall (MyClock, date+delay, refNum, delay, limit, a3); } } /* ....... */ long d; /* ....... */ d = MidiGetTime(); MyClock (d, myRefNum, 10L, d+30000L, 0L); /* Start now the clock for 30s */
As this call occurs under interruptions, a few precautions should be taken when using it, for example not invoking non-reentrant routines of the Operating System (such as the Memory Manager on the Macintosh for example). However, most of the MidiShare functions are reentrant, they can be used safely under interruption.
MidiShare was originally developed for Pascal on the Macintosh. Therefore, in C, all functions passed as arguments for a MidiShare function should be declared as Pascal. In the previous example, MyClock should be declared as :
pascal void MyClock(long date, short refNum, long delay, long limit, long a3);