Instantiates a COM object.

Syntax

Result = SRP_Com(Object, "CREATE", Name)

Returns

1 if the object was created successfully, 0 if there was an error.

Remarks

The CREATE service instantiates a new COM object. The object is returned via the Object parameter, not the return value. The return value is reserved for determining whether or not the object was successfully created. The Object parameter, if successful, will be a number. This number is the objects handle (or pointer) and should never be altered.

The Name parameter is used to identify the object you wish to create, and should be set to the objects Prog Id. The Prog Id is a string that uniquely identifies the object. For example, the Prog Id for the MSXML DOM object is Msxml2.DOMDocument.

As seen in the below example, the best way to use the CREATE service is to call it from within an If statement. That way, you can respond to errors in a way that is clean and readable, i.e., maintainable.

Example

 

// Instantiate the MSXML DOM Document object
If SRP_Com(objXmlDoc, "CREATE", "Msxml2.DOMDocument") then
     // Release the object when we're done with it
     SRP_Com(objXmlDoc, "RELEASE")
end else
     Error = SRP_Com("", "ERROR")
end