Public Method
A Public Method may be called from any other Procedure, by the Default plug-in as part of the CMS.
In large systems, Public Methods or Includes should be used whenever possible, such that Message Handlers, the Frontend Procedures, and Backend Procedures of Table Actions, Table Reports, Record Actions, and Record Reports are all able to call the Public Method when needed: if the same source code was instead placed directly inside another Procedure Type, it would not be accessible from other locations.
Parameters and Queries
The Parameters list of a Public Method may be one of the following prototypes:
- No Parameters
- Leave the Parameters blank
- One or more Input Parameters
- Specify the names of the Input Parameters, comma-separated
pOne, pTwo, pThree
- When the Public Method starts, these Parameters will be accessible as the Input Query, which is the default Top Query
- The Input Parameters are passed by copy - any changes to them within the called Public Method will not affect the values within the caller
- A new query named Table.ProcedureName.Output will be created on the calling side, and it will initially be empty
- When the Public Method starts, this query will be accessible as the Output Query, which is the default Work Query
- The Output Query is passed by reference - any changes to it within the called Public Method are returned to the caller
- One or more Input Parameters, with a named Output Query
- Specify the names of the Input Parameters, comma-separated, followed by a * as the last Parameter
pOne, pTwo, pThree, *
- When the Public Method starts, these Input Parameters will be accessible as the Input Query, which is the default Top Query
- The Input Parameters are passed by copy - any changes to them within the called Public Method will not affect the values within the caller
- When calling the Public Method, the last parameter may specify a specific query name. If the last parameter is omitted, the current Work Query will be used
- When the Public Method starts, this query will be accessible as the Output Query, which is the default Work Query
- The Output Query is passed by reference - any changes to it within the called Public Method are returned to the caller
- Named Input Query
- Set the Parameters to just a *
*
- When calling the Public Method, the one effective parameter may specify a specific query name. If the parameter is omitted, the current Work Query will be used
- When the Public Method starts, this query will be accessible as the Input Query, which is the default Top Query
- The Input Query is passed by reference - any changes to it within the called Public Method are returned to the caller
- A new query named Table.ProcedureName.Output will be created on the calling side, and it will initially be empty
- When the Public Method starts, this query will be accessible as the Output Query, which is the default Work Query
- The Output Query is passed by reference - any changes to it within the called Public Method are returned to the caller
- This is required for Procedures called from the Frontend CMS
- No Input Parameters, with a named Output Query
- Specify a blank Input Parameters list, followed by a * as the last Parameter
, *
- When the Public Method starts, an empty Input Query is created, which is the default Top Query
- Any changes to the Input Query within the called Public Method will not affect any values within the caller
- When calling the Public Method, the one effective parameter may specify a specific query name. If the parameter is omitted, the current Work Query will be used
- When the Public Method starts, this query will be accessible as the Output Query, which is the default Work Query
- The Output Query is passed by reference - any changes to it within the called Public Method are returned to the caller
- Named Input Query, with a named Output Query
- Set the Parameters to *, *
*, *
- When calling the Public Method, two, one, or no Parameters may be specified
- If two Parameters are provided, the first is the name of the Input Query, and the second the Output Query
- If one Parameter is provided, it is the name of the Input Query, and the current Work Query will be used as the Output Query
- If no Parameters are provided, the current Top Query will be used as the Input Query, and the current Work Query will be used as the Output Query
- When the Public Method starts
- The Input Query will be accessible as the Input Query, which is the default Top Query
- The Output Query will be accessible as the Output Query, which is the default Work Query
- Both the Input Query and the Ouput Query are passed by reference - any changes to them within the called Public Method are returned to the caller
Calling a Public Method
In order to call a Public Method elsewhere in MOX, the full dotted Database path name of the Table plus a dot-ProcName should be used: eg MemTab.Person.MyProc. Parameters should be listed following the same rules as any other statement/command in MOX.
The Call command allows the name of the Public Method being called to be dynamic by making the name of the public method the first parameter of the Call command.
The Thread command works the same as the Call command, but starts the Public Method in a new thread. When used for threads, the Public Method may only use specific Input Parameters; Input Queries and Output Queries are not supported.
Frontend Calls from the CMS
Default.dll contains the CMS and the Admin interface. They call Public Methods in the Content database tables to facilitate dynamic website content. For example, when the CMS is creating the Home page, which is stored in a record with the Alias of Home in the Content.Category Table, it attempts to run the Procedure named Home in the Content.Category Table.
These Public Methods must have a Parameters list set to *
, and the CMS will pass the record of the user who is currently logged in as the Input Query.
The Search feature of the CMS can be customized by creating a Public Method in the Content.Category Table named Search.
Request Query
A Query named Request will in most cases be created and populated with the HTTP(S) request data. Any changes made to this data will be discarded. The complete list of Request Query contents can be found under the headings of Builtin Values, Request Query on the Syntax and Buildin Values page.