« Back to Product

Documentation

IPS_GetFunctionList

Require: Symcon >= 2.6

 array IPS_GetFunctionList (int $InstanceID) 

Parameters

InstanceID

ID of the instance whose functions are returned, 0 for all functions

Returns

An array of string values of all function names. The order of the entries is not guaranteed.

Description

The function determines all available IPS functions that are available within the current configuration of IP Symcon. The names of the functions are listed in an array. The number of functions depends on the current configuration of IP Symcon. E.g., if the TTS (Text-To-Speech) module is available or a library was installed via the Module Store, its functions are listed as well.

The parameter InstanceID can be used to specify a filter. In that case, only functions of the specified instance are shown in the array. If the InstanceID is specified as 0, the filtering mechanism is not active and all available functions within IP Symcon will be returned.

Details about the individual functions can be determined by IPS_GetFunction.

Example

$allFunctions = IPS_GetFunctionList(0); 
print_r(IPS_GetFunction($allFunctions[48]));  // output only function 48 (IPS_CreateScript)

/* returns:
Array
(
    [FunctionName] => IPS_CreateScript
    [Parameters] => Array
    (
        [0] => Array
        (
            [Description] => ScriptType
            [Type_] => 1
        )
    
    )
    [Result] => Array
    (
        [Description] => Result
        [Type_] => 1
    )
)
*/

//Export all IP Symcon functions with a parameter list
$instanceid = 0; //0 = All functions, otherwise filter on InstanceID
$fs = IPS_GetFunctionList($instanceid);
asort($fs);
$typestr = Array("boolean", "integer", "float", "string", "variant", "array");
foreach($fs as $f) {
    $f = IPS_GetFunction($f);
    echo sprintf("[%7s]", $typestr[$f['Result']['Type_']]) . " - ".$f['FunctionName']."(";
    $a = Array();
    foreach($f['Parameters'] as $p) {
        if(isset($p['Enumeration']) && sizeof($p['Enumeration']) > 0) {
            $b=Array();
            foreach($p['Enumeration'] as $k => $v) {
                $b[] = $k."=".$v;
            }
            $type = "integer/enum[".implode(", ", $b)."]";
        } else {
            $type = $typestr[$p['Type_']];
        }
        $a[]=$type." $".$p['Description'];
    }
    echo implode(", ", $a).");\n";
}
Any questions?