External Command Programming Interface

The external command programming interface contains the functions described below.

IMPORTANT:  These functions require ICMD.NLM 2.18 or later.


ICMDSetVar

Use the ICMDSetVar function to set a script variable programmatically.


Function

int ICMDSetVar (char *variableName, char *variableValue)

*variableName: Pointer to name of variable to set
*variableValue: Pointer to string representing value of variable being set


Return

0 if successful; non-zero error code if unsuccessful.


Description

ICMDSetVar is a function exported by ICMD.NLM that another NLM can call (for instance, in a blocking NLMExec command). This lets the NLM set a variable within a script being executed by ICMD.NLM so the NLM can communicate with the script, changing the control flow, etc.


Example

If MYNLM.NLM has code as follows:

ICMDSetVar("mynlmvar", "hello world"); exit();

and the script looks like this:

NLMExec 1, mynlm

Display 0, "Information: %{mynlmvar}"

then this popup text box would be displayed:

Information: hello world

ICMDGetVar

Use the ICMDGetVar function to get the value of a script variable.


Function

int ICMDGetVar (char *variableName, char *variableValue)

*variableName: Pointer to name of variable
*variableValue: Buffer containing value of variable; must be at least 128 bytes


Return

0 if successful; non-zero error code if unsuccessful or if variableName does not exist.


Description

ICMDGetVar is a function exported by ICMD.NLM that another NLM can call. This lets the NLM set a variable within a script being executed by ICMD.NLM so the NLM can communicate with the script, changing the control flow, etc.


Example

If a script looks like this:

SetVar myvar, "Hello"

NLMExec 1, mynlm

and if MYNLM.NLM has code as follows:

char buffer[128];

ICMDGetVar("myvar", buffer);

then the value in buffer would be the null-terminated string:

"Hello".