Copying Templates
After you've looked up a Toolbox routine, it's likely that you'll want to use
it in your program. Use the Copy Template command in the Edit menu to put a calling template in the clipboard, then go to your programming
environment and paste it into your program. The Preferences
command lets you choose whether the templates should be in C or in Pascal.
For example, suppose that you looked up SFGetFile and now you want to call
it in your program. Choose Copy Template from the Edit menu. When you go back to your programming environment and use its Paste command, you'll see this in C:
SFGetFile ( where, prompt, fileFilter, numTypes, typeList,
dlgHook, &reply );
or in Pascal:
SFGetFile ( where, prompt, fileFilter, numTypes, typeList,
dlgHook, reply );
THINK Reference tries to be intelligent about the template it places in the
clipboard. If the Toolbox routine returns a value, it will set up an
assignment statement like this:
hNew = NewHandle ( dataSize );
or in Pascal:
hNew := NewHandle ( dataSize );
If the routine returns a Boolean, it will set up an if statement like this:
if ( GetNextEvent ( eventMask, &theEvent ) ) {
or in Pascal:
if ( GetNextEvent ( eventMask, theEvent ) ) then begin
Of course, THINK Reference can only suggest a Toolbox call template. It
can't know what your variable names really are. In the case of the
GetNextEvent call above, THINK Reference is reminding you that theEvent
should be passed by reference not by value. If theEvent in your program is
already a pointer, you would remove the & operator.
The Preferences command in the Edit menu lets you choose between C and Pascal templates and you can choose whether there should be
spaces before and after paren theses.