Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

CreateObject

  • Last UpdatedFeb 28, 2024
  • 2 minute read

Creates a new instance of an ActiveX object. If you use this function to create an ActiveX object, it will have no visual component (only the automation component will be created).

If you assign an object created with the CreateObject function to a local variable, that object will remain in existence until the variable it is assigned to goes out of scope. This means that such an object will only be released when the Cicode function that created it ends.

If you assign an object created with the CreateObject function to a module or global scope variable, then that object will remain in existence until the variable either has another object assigned or is set to NullObject, provided the CreateObject call is not made within a loop.

Objects created by calls to CreateObject within WHILE or FOR loops are only released on termination of the Cicode function in which they are created, regardless of the scope of the variable to which the object is assigned. The use of CreateObject within a loop may therefore result in the exhaustion of system resources, and is not generally recommended unless performed as shown in the examples below.

Note: ActiveX objects are not supported on a 64-bit process, such as an alarm server operating in Extended Memory mode. If a call to this function occurs from a 64-bit process, an error code will be returned, a hardware alarm will be raised and the Cicode thread will stop.
For information regarding methods you can use to extend Plant SCADA that do not require ActiveX, see the topic Extensibility in the Plant SCADA documentation.

warning2

UNINTENDED EQUIPMENT OPERATION

Do not use the CreateObject() function within a loop except in strict accordance with the following instructions.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

Syntax

OBJECT CreateObject(sClass)

sClass:

The class of the object. You can use the object's human readable name, its program ID, or its GUID. If the class does not exist, the function will return an error.

For example:

• "Calendar Control 8.0" - human readable name

• "MSCAL.Calendar.7" - Program ID

• "{8E27C92B-1264-101C-8A2F-040224009C02}" - GUID

Return Value

The newly created object, if successful, otherwise an error is generated.

DspAnCreateControlObject, CreateControlObject

Example

The following examples show correct techniques for calling CreateObject() within a loop.

/* In the example below, the variable objTest is local. Resources
associated with calls to ProcessObject() will be released each
time that function ends. */
FUNCTION Forever()

WHILE 1 DO

ProcessObject();

Sleep(1);

END

END

FUNCTION ProcessObject()

.OBJECT objTest;

objTest=CreateObject("MyObject");

- do something

END

/* In the example below, the variable objTest is global. Resources
associated with calls to ProcessObject() will be released when
objTest is set to NullObject. */

FUNCTION Forever()

WHILE 1 DO

ProcessObject();

Sleep(1);

END

END
FUNCTION ProcessObject()

objTest=CreateObject("MyObject");

- do something

objTest=NullObject;

END

See Also

ActiveX Functions

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in