Difference between revisions of "Methods handling"

From SDU
Jump to: navigation, search
m (Reverted edits by Agegeleruvy (Talk); changed back to last version by FrankTR)
 
Line 1: Line 1:
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://awibuky.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
 
----
 
=[http://awibuky.co.cc CLICK HERE]=
 
----
 
</div>
 
 
__NOTOC__
 
__NOTOC__
 
[[Category:Customizations]]
 
[[Category:Customizations]]
Line 18: Line 10:
  
 
Here is an example of trigger (call method ''convert_request'' with one parameter):
 
Here is an example of trigger (call method ''convert_request'' with one parameter):
&lt;source lang=&quot;text&quot;&gt;
+
<source lang="text">
POST_VALIDATE convert_request( persistent_id ) 96 FILTER(EVENT(&quot;INSERT&quot;));
+
POST_VALIDATE convert_request( persistent_id ) 96 FILTER(EVENT("INSERT"));
&lt;/source&gt;
+
</source>
  
 
== Method definition ==
 
== Method definition ==
Line 26: Line 18:
  
 
Here is the base structure of new method called '''newMethod''' on object '''cr''' with variable number of parameters:
 
Here is the base structure of new method called '''newMethod''' on object '''cr''' with variable number of parameters:
&lt;source lang=&quot;javascript&quot;&gt;
+
<source lang="javascript">
 
void cr::newMethod (...)
 
void cr::newMethod (...)
 
{
 
{
 
      
 
      
 
}
 
}
&lt;/source&gt;
+
</source>
 
Use method definition with ''(...)'' even if no parameters are expected.
 
Use method definition with ''(...)'' even if no parameters are expected.
  

Latest revision as of 05:25, 30 November 2010

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.