COM Interface
The COM Interface definition is used to connect TDL with external functionalities available in COM-based DLLs. It is defined with details such as name, return type, and parameters, which TDL later uses to invoke these functions. It acts as a bridge that allows TDL to invoke functions written outside Tally, such as system APIs or third-party libraries. Whether it is to enable text-to-speech, interact with external applications, or perform system-level operations, COM Interface makes it possible to extend TDL capabilities beyond its native scope.
Syntax
[COM Interface: <COM Interface name>]
➥ Click here to download COM Interface Sample
Attributes
The Class attribute specifies the exact class within the external project or DLL that contains the function to be executed — helping TDL locate the correct implementation when multiple classes exist. Think of it as selecting the right container that holds the functionality you want to use.
Syntax
[COM Interface: <COM Interface name>]
Class : <Class Name>
Example
[COM Interface: TSPL Smp Voice Interface]
Project : Sapi
Class : SpVoice
Interface : Speak
Parameter : P1 : String
This example demonstrates how to use the SpVoice class from the SAPI library. The SpVoice class provides speech functions, and by specifying it, TDL knows where to find the Speak method to convert text into speech.
The Interface attribute defines the exact function to be called from the selected class — representing the specific action or operation executed when the COM Interface is invoked.
Syntax
[COM Interface: <COM Interface name>]
Interface : <Name of the function to be invoked>
Example
[COM Interface: TSPL Smp Voice Interface]
Project : Sapi
Class : SpVoice
Interface : Speak
Parameter : P1 : String
This example demonstrates how to use the Speak method. The Speak method takes the given text as input and uses the system’s voice engine to convert it into speech.
The Parameter attribute is used to define the inputs required by the external function. It specifies the name, data type, and direction (In/Out) of each parameter, ensuring that the correct data is passed during execution. You can define multiple parameters if the function requires more than one input.
Syntax
[COM Interface: <COM Interface name>]
Parameter : <Parameter Name> : <Data Type>[:<Nature of Parameter>]
Example
[COM Interface: TSPL Smp Voice Interface]
Project : Sapi
Class : SpVoice
Interface : Speak
Parameter : P1 : String
This example demonstrates how to pass a parameter to the Speak method. Here, P1 is the parameter name, and it accepts a String value. The text passed through this parameter is used by the Speak method and is spoken aloud using the system’s voice engine.
The Project attribute specifies the external project or namespace that contains the required class. It acts as the entry point for locating the class and its associated functions.
This ensures that TDL connects to the correct external library.
Syntax
[COM Interface: <COM Interface name>]
Project : <Project/Namespace>
Example
[COM Interface: TSPL Smp Voice Interface]
Project : Sapi
Class : SpVoice
Interface : Speak
Parameter : P1 : String
This example demonstrates how to use the SAPI library. SAPI (Microsoft Speech API) is the library that provides speech-related functionality. By specifying SAPI, TDL knows which external DLL to use for executing speech functions.
The Return attribute defines the type of value that the external function will return after execution. It helps TDL understand what kind of output to expect and how to handle it.
This attribute is optional and is used only when the function provides a return value.
Syntax
[COM Interface: <COM Interface name>]
Return : <Return Data Type>
Example
[COM Interface: TSPL Smp Voice Interface]
Return : Number
This example demonstrates how to handle a numeric return value from a function. By specifying Number as the return type, TDL knows that the function returns a numeric value (such as a status code) and captures it correctly.
