The mechanism for including resource databases in your project will be explained in a later chapter. Briefly, you must use the Constants Browser to create one or more named constants containing the filenames of the resource databases to use.
fontHeight := SYSTRAP FntCharHeight.If an API function takes arguments, you write the SYSTRAP line as a keyword message-send. The first keyword is taken to be the function name and the other keywords can be anything you want. For example, to draw a line from the top-left corner of the screen to the bottom-right:
SYSTRAP WinDrawLine: 0 y: 0 x: 160 y: 160.Note that the most common SYSTRAP calls are already encapsulated in appropriate methods in the standard Smalltalk class library, so you will only rarely have to deal with SYSTRAP calls directly.
You must be careful to pass the correct types of arguments to PalmOS API functions. Arguments must either be Smalltalk Integers or CPointers. In particular, boolean arguments must be either 0 or 1, not true or false. If you pass incorrect argument types to an API function the receiver of the method that made the incorrect call is sent #badAPICall, which by default signals an error. You can see what parameters an API call expects by using the SYSTRAP Browser.
Some PalmOS API calls expect a pointer to a string, along with a separate length parameter. You can convert a Smalltalk String to a pointer to a C string by sending the String #copyToHeap. You must be sure to free the pointer after use by sending #free to the CPointer object. As a special feature, you can simply pass a byte-indexable object (such as a Smalltalk String) as the pointer to a string, instead of converting the String to a C-readable string. You still need to pass the length argument. This technique cannot be used with functions that expect 0-terminated strings, as Pocket Smalltalk Strings are not 0-terminated.