Using libraries

Load and initializing the library

#include
int MathLibRef = -1;
...
// is library already loaded?
err = SysLibFind("MathLib", &MathLibRef);
if (err != 0) {
  // negative, load
  err = SysLibLoad('libr', 'MthL', &MathLibRef);
  if (err == 0) {
    err = MathLibOpen (MathLibRef, 1);
  }
}

Closing library

if (MathLibRef != -1) {
  Err err;
  UInt16 usecount;
  err = MathLibClose (MathLibRef, &usecount);
  if (usecount == 0) {
    SysLibRemove (MathLibRef);
  }
}