An important point to note regarding the Telecom Engine language is that there are no ‘built-in’ functions. All external functionality for operations such as console input/output, database access, speech and network card functionality, inter-process communications etc. are all implemented as DLLs. The language itself does not include any of these functions as part of the language definition, which means that the language is not tied down to any particular hardware vendor or to any specific implementation.
However without any of the above functionality the language would be pretty useless, therefore a set of DLLs is provided that offer most of the functions that are required for the implementation of telecommunication applications. This set of functions will be referred to as the TE standard function set. However, since these functions are implemented as DLLs there is no reason why these could not be extended or even completely replaced with another implementation if so desired.
In the following description of the TE language, all external functions used in the examples will be one of those from TE Standard function set. For a full description of these functions see the TE Standard Library Set reference manual.
As is usual will all programming guides we will start with an example ‘Hello World’ application:
main
applog("Hello World");
endmain
All Telecom Engine programs consist of a pair of main … endmain statements between which the application statements are written. In the above application the applog() function writes the string "Hello World" to the application console and to the application log file . This function is provided by the CXTERMX.DLL function library (See TE Standard Library Set Manual).
This is not a very useful program for a telecommunications system so lets move quickly to another example using the Aculab functions provided by the CXACULAB.DLL and CXACUDSP.DLL function libraries:
$include "aculab.inc"
int port, chan, vox_chan, x;
var filename:64;
main
port=0
chan=1;
vox_chan=1;
filename="hello.vox";
// Make full duplex H.100 bus routing between vox channel and network port/channel
CClisten(port,chan,SMgetslot(vox_chan));
SMlisten(vox_chan, CCgetslot(port, chan));
// Enable inbound calls on this port/channel
CCenablein(port,chan);
// loop waiting for incoming call
while(1)
x=CCwait(port,chan,CC_WAIT_FOREVER);
if(x == CS_INCOMING_CALL_DETECTED)
break;
endif
endwhile
// Answer the call
CCaccept(port,chan);
// Play a vox file to caller
SMplay(vox_chan,filename);
// Hangup the call
CCdisconnect(port,chan,CAUSE_NORMAL);
// Wait for state to return to IDLE the release call
while(1)
x=CCwait(port,chan,CC_WAIT_FOREVER);
if(x == CS_IDLE)
break;
endif
endwhile
// release the call
CCrelease(port,chan);
// restart the application to wait for another call..
restart;
endmain
This program initialises a port/channel on an Aculab E1/T1 board for incoming calls (CCenablein()) , then enters a loop waiting for inbound calls (CCwait()). Upon receiving an inbound call it answers the call (CCaccept()), plays a speech file (SMplay()), then finally hangs-up the call and releases the call handle before restarting the program to wait for the next call. This could be considered the ‘Hello World’ of telecommunications programming.
Readers with some familiarity with ‘C’ will notice a few similarities between the TE language and ‘C’. However where ‘C’ uses curly braces ( { and } ) to delimit statement blocks, the Telecom engine used if…else…endif, while…endwhile, for…endfor, do…until(), switch…endswitch, etc.
The first statement in the above application is as follows:
$include "aculab.inc"
This statement instructs the compiler to include the contents of the file “aculab.inc” into the program file as though the statements contained in “aculab.inc” had been typed directly into the program file. These files are usually used to define common global variables or constant definitions (for example the CS_INCOMING_CALL_DETECTED, CC_WAITFOREVER, CS_IDLE are all defined in the "aculab.inc" file.) and are often known as ‘header’ files (usually with “.inc” or “.h” extensions).
The statements after the $include in the program show the declaration of some global variables. There are two types of variables allowed in the TE language: ‘var’ and ‘int’ types. Actually all variables in the Telecom Engine are stored as ASCII strings and the only difference between the type ‘var’ and the type ‘int’ is that the TE run-time engine will automatically convert the values stored into ‘int’ types to a numeric representation of the string. So if you assign the string “abc” to a variable of type ‘var’ then “abc” is what would be stored in the variable, whereas if you attempt to assign “abc” to a variable of type ‘int’ then this will be evaluated to 0 and the string “0” will be stored into the variable. This is described in more detail later.
At the top of the main program section you will see the global variables being initialised then the functions from the CXACULAB.DLL and CXACUDSP.DLL libraries are called to wait for a call, accept the call, play a speech file ("hello.vox") then hang-up and release the call.
Finally the restart statement instructions the TE runtime engine to clear all variables and start again from the top.
Throughout the code you will notice that comments are included by prefixing the comment by // characters. All text from the // marker to the end of the current line are ignored by the compiler. Alternatively comments may also be prefixed with the # character depending on the preference of the programmer.