« Back to Product

Documentation

IPS_GetObjectIDByIdent

Require: IP-Symcon >= 2.5

 int IPS_GetObjectIDByIdent (string $ObjectIdent, int $ParentID) 

Parameters

ObjectIdent

The searched object identificator

ParentID

ID of the object whose children object are searched

Returns

ID of the found object, otherwise FALSE

Description

This function tries to detect the object with the ident ObjectIdent whose parent object has the ID ParentID. If such an object is found, its ID is returned. Otherwise, this function returns FALSE.

Warning

The parameter "ObjectIdent" must not be an empty string ("").

Warning

__Difference to IPS_GetObjectIDByName:__ As idents of objects are unique within an individual level, either a single ID is returned or a warning is generated.

Warning

This function generates a warning if the ident is not found. The @ operator can be used to supress this message. Please see the PHP manual for the exact functionality of this operator.

Example

// This function can be used to replace IPS_StatusVariableExists
// Example for IPS_StatusVariableExists($id, "StatusVariable");
echo !(@IPS_GetObjectIDByIdent("StatusVariable", $id) === false); 

// In addition, the function can be used to replace IPS_GetStatusVariableID
// Example for IPS_GetStatusVariableID($id, "StatusVariable");
echo IPS_GetObjectIDByIdent("StatusVariable", $id);
        
        
$id = IPS_GetObjectIDByIdent($VariableIdent, $InstanceID);        
$v = IPS_GetVariable($id);

// Array since 4.0
$sv = Array(
    "VariableID" => $id,
    "VariableIdent" => $VariableIdent,
    "VariableName" => "N/A",
    "VariablePosition" => 0,
    "VariableProfile" => $v['VariableProfile'],
    "VariableType" => $v['VariableType'],
    "VariableHasAction" => ($v['VariableAction'] > 0),
    "VariableUseAction" => ($v['VariableAction'] > 0)
);

// Array until 3.4
$sv = Array(
    "VariableID" => $id,
    "VariableIdent" => $VariableIdent,
    "VariableName" => "N/A",
    "VariablePosition" => 0,
    "VariableProfile" => $v['VariableProfile'],
    "VariableType" => $v['VariableValue']['ValueType'],
    "VariableHasAction" => ($v['VariableAction'] > 0),
    "VariableUseAction" => ($v['VariableAction'] > 0)
);
Any questions?