Methods¶
AMIDB methods can be used anywhere within the console, and on top of other functionalities like triggers, procedures and timers. They are a useful way to reuse code and make projects easier to maintain.
CREATE METHOD¶
To create a custom method, the syntax is as follows:
For example, to create a simple method (called foo) to return the sum of two numbers (of Integer type):
This method can now be called/used inside of timers/procedures/triggers. E.g. for a procedure
Method Overloading¶
Like in Java, method overloading is supported by AMI, which allows for methods with the same name but different parameters to be created.
For example, if we currently have int foo(int a, int b)
, which returns the sum of two Integers, we can overload the method to return the sum of two doubles as well, with:
AMI will auto-resolve the method to use based on the parameters used in the method call.
DROP METHOD¶
To drop our newly created method foo:
SHOW METHODS¶
To view all available methods, use: