%OpenRefToObject function


Function
The function %OpenRefToObject asks the system for accessing Object Values which are defined with the Unique Identifier HOBJ.
Declaration
BOOL %OpenRefToObject(
   HBJ in _hbj,
   BOOL in _bSynchro
 )
Parameters
_hbjValue of the HBJ type or INT type.
_bSynchroValue of the Boolean type.
Description
The function allows to ask the system for accessing Object Values which are defined with Unique Identifier HOBJ. The values are accessed to all ESL scripts which are interpreted in the actual process (the D2000 HI or D2000 EventHandler) by this function.
The using of this function is recommended in the case that the object (its HOBJ is mentioned when the function is called) is not directly in the script and the system do not know automatically, that Object Values are required for the script.
Example
If the User Tag U.Test (value type Integer) has HOBJ 1234 then the following script will generate the run-time error (_ERR_OBJECT_NOT_FOUND) or the local variable _val will be incorrect:
 
 INT _val
 ALIAS _a
 
 SET_a AS (1234) 
 
 ; incorrect row
 _val:= _a 

The user can avoid this status by using this function %OpenRefToObject(IN HBJ _hbj, IN BOOL _bSynchro):
 
 BOOL _openOk 
 INT _val 
 ALIAS _a 
 
 SET _a AS (1234) 
 _openOk:= %OpenRefToObject(_a\HBJ,@TRUE) 
 
 IF _openOk  THEN 
 ;the row is correct
 _val:= _a 
 ELSE 
  ;an object with HOBJ 1234 does not exist !!! 
  ENDIF
 
The parameter _bSynchro is set on @TRUE. This setting allows to check through the return value of the function if the object with the required HOBJ exists. The first calling of the function in actual process communicates with the D2000 Server process synchronously. The existence of the object is checked. This activity can run some time. If the object exists then next calling is quick.

If the parameter is set on @FALSE the script will send the request for opening the object and will proceed. The return value of the function is @TRUE and that is why it is not possible to check the existence of the object with defined HOBJ.

Note
If the script do not ask for Object Value the system is informed by the function %CloseRefToObject.

0 komentárov

Nie ste prihlásený. Akékoľvek zmeny, ktoré vykonáte, sa označia ako anonymné. Ak už máte svoj účet, pravdepodobne sa budete chcieť prihlásiť .