Difference between revisions of "Methods handling"
(reverting vandalism) |
Agegeleruvy (Talk | contribs) |
||
| 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 10: | Line 18: | ||
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): | ||
| − | + | <source lang="text"> | |
| − | POST_VALIDATE convert_request( persistent_id ) 96 FILTER(EVENT( | + | POST_VALIDATE convert_request( persistent_id ) 96 FILTER(EVENT("INSERT")); |
| − | + | </source> | |
== Method definition == | == Method definition == | ||
| Line 18: | Line 26: | ||
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: | ||
| − | + | <source lang="javascript"> | |
void cr::newMethod (...) | void cr::newMethod (...) | ||
{ | { | ||
} | } | ||
| − | + | </source> | |
Use method definition with ''(...)'' even if no parameters are expected. | Use method definition with ''(...)'' even if no parameters are expected. | ||
Revision as of 03:30, 24 November 2010
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.