Opening and Closing Components

The OpenDefaultComponent, and CloseComponent functions allow your application to gain access to and release components. Your application must open a component before it can use the services provided by that component. Similarly, your application must close the component when it is finished using the component.

You can use the OpenDefaultComponent function to open a component of a specified component type and subtype.

Once you are finished using a component, use the CloseComponent function to release the component.

OpenDefaultComponent

The OpenDefaultComponent function allows your application to gain access to the services provided by a component. Your application must open a component before it can call any component functions. You specify the component type and subtype values of the component to open. The Component Manager searches for a component that meets those criteria. If you want to exert more control over the selection process, you can use the FindNextComponent and OpenComponent functions.

FUNCTION OpenDefaultComponent (componentType as String, componentSubType as String) as ComponentInstance

componentType
A four-character code that identifies the type of component. All components of a particular type support a common set of interface routines. Your application uses this field to search for components of a given type.
componentSubType
A four-character code that identifies the subtype of the component. Different subtypes of a component type may support additional features or provide interfaces that extend beyond the standard routines for a given component type. For example, the subtype of an image compressor component indicates the compression algorithm employed by the compressor.
Your application can use the componentSubType field to perform a more specific lookup operation than is possible using only the componentType field. For example, you may want your application to use only components of a certain component type ( 'draw' ) that also have a specific subtype ( 'oval' ). Set this parameter to 0 to select a component with any subtype value.

DESCRIPTION

The OpenDefaultComponent function searches its list of registered components for a component that meets the search criteria. If it finds a component that matches the search criteria, OpenDefaultComponent opens a connection to the component and returns a component instance. The returned component instance identifies your application's connection to the component. You must supply this component instance whenever you call the functions provided by the component When you close the component, you must also supply this component instance to the CloseComponent function.

If more than one component in the list of registered components meets the search criteria, OpenDefaultComponent opens the first one that it finds in its list.

If it cannot open the specfied component, the OpenDefaultComponent function returns a function result of NIL .

CloseComponent

The CloseComponent function terminates your application's access to the services provided by a component. Your application specifies the connection to be closed with the component instance returned by the OpenComponent or OpenDefaultComponent function.

CloseComponent aComponentInstance as ComponentInstance

aComponentInstance
A component instance that specifies the connection to close. Your application obtains the component instance from the OpenComponent function or the OpenDefaultComponent function.

DESCRIPTION

The CloseComponent function closes only a single connection. If your application has several connections to a single component, you must call the CloseComponent function once for each connection.