Article # 224, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
Declaring a Method As a Routine
If you have a class called HelloCounterClass then the "truncated" class name is HelloCounter. The name of the message type for that class is HelloCounterMessages. Thus all messages defined in HelloCounterClass are of type HelloCounterMessages. Shown below is the definition of the MSG_HELLO_COUNTER_RECALCULATE_VALUE message, the function prototype for HelloCounterRecalculateValue, and how the the method and function can be combined into one. This saves space and makes the purpose of the code more clear. @class HelloCounterClass; @message int MSG_HELLO_COUNTER_RECALCULATE_VALUE( HelloPriority priority, word randomDatum, char aLetter ); @endc; /* * Function prototype, used if functions will call this * routine and the compiler hasn't see the routine * definition yet (i.e. it's defined in another file). */ extern int _pascal HelloCounterRecalculateValue( optr oself, HelloCounterMessages message, HelloPriority priority, word randomDatum, char aLetter ); /* * Here's where we combine the method and the function * into one unit of code to save space. */ @method HelloCounterRecalculate, HelloCounterClass, MSG_HELLO_COUNTER_RECALCULATE_VALUE { /* method code goes here... */ }