Documentation
IPS_GetActionReadableCode
string IPS_GetActionReadableCode (string $ActionID, array $Parameters)
Parameters
| ActionID | GUID of the action |
| Parameters | Parameters of the action, at least TARGET, PARENT and ENVIRONMENT |
Returns
PHP code that executes the action with the given parameters.
Description
The function returns the action with the GUID ActionID and the parameters Parameters as readable PHP code, which can e.g. be inserted into a script. The management console uses this in the "Add command" dialog of the script editor.
- If the action has no entry readable, the PHP code of the action (entry action) is returned, with every
$_IPS['NAME']replaced by the value of the parameter NAME: Boolean as true/false, Integer and Float as number, String in double quotes. Parameters that are not passed remain as$_IPS['...']. If the action is defined as an array of code lines, each line ends with a line break. - If the action has an entry readable, this PHP code is run with the parameters as system variables and its output is returned. The function waits until the execution has finished.
The Parameters need to include the following entries:
| Parameter | Description |
|---|---|
| TARGET | ID of the target object of the action (-1 for general actions) |
| PARENT | ID of the object that executes the action, e.g. the PHP script or the flow script |
| ENVIRONMENT | The environment of the action, see Environments |
Only Boolean, Integer, Float and String are possible as values. If the action does not exist, the function fails with "Action with ID ... not found!", then the required parameters are checked ("TARGET is missing in Parameters", "PARENT is missing in Parameters", "ENVIRONMENT is missing in Parameters"). If the entry readable is invalid, it fails with "Readable Field of Action ... is invalid!".
An action is executed with IPS_RunAction or IPS_RunActionWait.
Example
echo IPS_GetActionReadableCode('{46B65CA6-3098-4982-9A6C-B89DADBB0A96}', [
'TARGET' => 12345, // Boolean variable
'PARENT' => $_IPS['SELF'],
'ENVIRONMENT' => 'Default',
'VALUE' => true
]);
/* returns:
RequestAction(12345, true);
*/