Methods handling

From SDU
Jump to: navigation, search
To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.

Method calling

Methods can be called from triggers or using Send_wait function.

Here is an example of trigger (call method convert_request with one parameter): <source lang="text"> POST_VALIDATE convert_request( persistent_id ) 96 FILTER(EVENT("INSERT")); </source>

Method definition

You can define new methods on every object. This definition must be in file with SPL extension in $NX_ROOT/site/mods/majic folder. In one file you can define more than one method and even for more than one class.

Here is the base structure of new method called newMethod on object cr with variable number of parameters: <source lang="javascript"> void cr::newMethod (...) {

} </source> Use method definition with (...) even if no parameters are expected.

Parameters handling

Parameters are passed into the method in argv array. Each parameters are in triplets. Here is the explanation of argv values:

  • argv[0] - number of parameters
  • argv[1] - name of the first parameter
  • argv[2] - previous value of the first parameter
  • argv[3] - actual value of the first parameter
  • argv[4] - name of the second parameter
  • argv[5] - previous value of the second parameter
  • argv[6] - actual value of the second parameter

and so on

Overriding methods

If you want to override some built-in method, simply define method with the same name (object::methodName) and write your new body.