Difference between revisions of "Catglobe modules"
Wikicatglobe (talk | contribs) |
|||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | <accesscontrol> | + | <accesscontrol>Main:MyGroup</accesscontrol> |
− | [[Category: | + | [[Category:Miscellaneous]] |
= Catglobe modules = | = Catglobe modules = | ||
Latest revision as of 11:36, 17 October 2013
<accesscontrol>Main:MyGroup</accesscontrol>
Contents
Catglobe modules
Using CG Script it's possible to build very complex solutions on top of the Catglobe platform. This page and sub pages offers some guidelines on how to use existing Catglobe modules and how to extend with additional generic modules, or create and register customized modules which are used by a specific solution.
Building a new solutioin, where Catglobe modules are used as the foundation, helps you abstract from tedious things like remembering the resource ids of a lot of generic workflows, it also makes it easier to move your solution to other Catglobe sites once it's done.
One workflow resource id must be known in order to initialize the Catglobe modules framework, namely the resource id of the Catglobe module loader.
Initializing the module loader
The Catglobe module loader is the workflow module responsible for loading all other generic Catglobe modules, the script below demonstrates how to initialize the module loader and add a few generic Catglobe modules:
number moduleLoaderResId = 1234;
Dictionary cgmod = Workflow_call(moduleLoaderResId, {
"Catglobe.DateTime",
"Catglobe.Text"
});
Let's go through the code above line by line. At line 1 we specify the resource id of the workflow which contains the Catglobe module loader. Line 2 calls the workflow with an array of strings indicating to the module loader which generic Catglobe modules we would like to load initially, in the example above we load Catglobe.DateTime and Catglobe.Text which allows us to manipulate date or time, and text respectively.
Delayed module inclusion
Not all modules have to be loaded initially. Depending on the flow through your workflow it's possible to delay inclusion of the generic modules until they are actually needed, the next example demonstrates how to load the Catglobe.Text module after the module loader was initialized:
number moduleLoaderResId = 1234;
Dictionary cgmod = Workflow_call(moduleLoaderResId, {
"Catglobe.DateTime"
});
cgmod["Catglobe.ModuleLoader"]["load"].Call({
"Catglobe.Text"
});
As in the first example we initially load the Catglobe module loader, this time we initialize with only the Catglobe.DateTime module. At line 5 we call the function "load" defined in the Catglobe.ModuleLoader module which takes an array of strings specifying names of generic Catglobe modules to be loaded. Modules which have already been loaded are not loaded again.
Listing loaded modules
Sometimes it might be useful to see which modules have been loaded already, this can be done using the listAvailableModules function, the following example shows how to use it:
number moduleLoaderResId = 1234;
Dictionary cgmod = Workflow_call(moduleLoaderResId, {
"Catglobe.DateTime",
"Catglobe.Text"
});
Array moduleNames = cgmod["Catglobe.ModuleLoader"]["listAvailableModules"].Call();
for (number i = 0; i < moduleNames.Count; i++) {
print(moduleNames[i]);
}
The script above will output:
Catglobe.DateTime Catglobe.Text
Further reading
How to create a generic Catglobe module
How to create a solution specific module