CallPlugin
Script function

world.CallPlugin

DOC_scripting Read about scripting

Type

Method

Summary

Calls a routine in a plugin

Prototype

long CallPlugin(BSTR PluginID, BSTR Routine, BSTR Argument);

DOC_data_types View list of data type meanings


Description

Calls a nominated routine in a nominated plugin, supplying a string argument.

The intention here is to allow plugins to interact with each other, to a certain extent.

For instance, you might write a plugin that logs text to a log file, and want to share it between other plugins. Hence you might log a message like this:

world.CallPlugin "80cc18937a2aca27079567f0", "LogIt", "Data to be logged"

The above example would locate plugin with the ID 80cc18937a2aca27079567f0 (if installed) and then call the routine "LogIt" in that plugin, with the argument "Data to be logged". In this example, the LogIt routine would look like this:

Sub LogIt (sText)
world.WriteLog sText
End Sub


You should exercise caution when using this technique. It will be annoying for plugin users if plugins become overly dependent on each other, particularly if they cannot find the one that is required.

Also, be careful you do not set up circular dependencies (eg. A needs B, and B needs A).

You can use "world.PluginSupports" to see if a particular routine is implemented in a plugin. For example:

If world.PluginSupports ("80cc18937a2aca27079567f0", "LogIt") <> eOK then
world.Note "Required 'LogIt' routine is not available"
End If


If you want to send a message to all installed plugins you might consider using BroadcastPlugin instead.



VBscript example

world.CallPlugin "80cc18937a2aca27079567f0", "LogIt", "Data to be logged"



Jscript example

world.CallPlugin ("80cc18937a2aca27079567f0", "LogIt", "Data to be logged");



PerlScript example

$world->CallPlugin ("80cc18937a2aca27079567f0", "LogIt", "Data to be logged");



Python example

world.CallPlugin ("80cc18937a2aca27079567f0", "LogIt", "Data to be logged")



Lua example

CallPlugin ("80cc18937a2aca27079567f0", "LogIt", "Data to be logged")



Lua notes

The Argument parameter is optional, and defaults to an empty string.



Return value

eNoSuchPlugin: Plugin not installed
ePluginDisabled: Plugin is disabled
eNoSuchRoutine: Specified routine cannot be found in that plugin
eErrorCallingPluginRoutine: Error when calling routine (eg. syntax error)
eOK: Called OK


DOC_errors View list of return code meanings


See Also ...

Topics

DOC_aliases Aliases
DOC_Arrays Arrays
DOC_plugins Plugins
DOC_scripting Scripting
DOC_timers Timers
DOC_triggers Triggers
DOC_variables Variables

Functions

FNC_BroadcastPlugin BroadcastPlugin (Broadcasts a message to all installed plugins)
FNC_EnablePlugin EnablePlugin (Enables or disables the specified plugin)
FNC_GetPluginID GetPluginID (Returns the 24-character ID of the current plugin)
FNC_GetPluginInfo GetPluginInfo (Gets details about a specified plugin)
FNC_GetPluginList GetPluginList (Gets a list of installed plugins.)
FNC_GetPluginName GetPluginName (Returns the name of the current plugin)
FNC_GetPluginTimerInfo GetPluginTimerInfo (Gets details about a named timer for a specified plugin)
FNC_GetPluginTimerList GetPluginTimerList (Gets the list of timers in a specified plugin)
FNC_GetPluginVariable GetPluginVariable (Gets the contents of a variable belonging to a plugin)
FNC_GetPluginVariableList GetPluginVariableList (Gets the list of variables in a specified plugin)
FNC_IsPluginInstalled IsPluginInstalled (Checks to see if a particular plugin is installed)
FNC_LoadPlugin LoadPlugin (Loads a plugin from disk)
FNC_PluginSupports PluginSupports (Checks if a plugin supports a particular routine)
FNC_ReloadPlugin ReloadPlugin (Reloads an installed plugin)
FNC_SaveState SaveState (Saves the state of the current plugin)

(Help topic: function=CallPlugin)

DOC_contents Documentation contents page