Transaction Script Language (TSL) Reference Manual
Transaction Script Language (TSL) Reference Manual
Transaction Script Language (TSL) Reference Manual
Reference Manual
TRANSACTION SCRIPT LANGUAGE (TSL)
REFERENCE MANUAL
Table Of Contents
1 Transaction Script Language
1.1 Introduction ............................................................................................. 1-1
3 Function
3.1 Function Declaration ............................................................................... 3-1
3.2 Function Calls ......................................................................................... 3-2
3.3 Function Parameters ................................................................................ 3-3
3.4 Parameter and Return Value Size............................................................ 3-4
© 1996 - 2006 Teligent AB Id-008725 Rev A3
4 Transactions
4.1 trns Transaction Declaration ................................................................... 4-1
4.1.1 Transaction Type................................................................................. 4-1
4.1.2 Transaction Class ................................................................................ 4-1
5 Statements
5.1 The if-else Statement ............................................................................... 5-1
5.2 The send Statement.................................................................................. 5-1
5.3 The wait Statement .................................................................................. 5-1
5.4 The while and break Statements .............................................................. 5-2
5.5 The debug, log, info and error Statements............................................... 5-2
5.6 The call Statement ................................................................................... 5-2
5.7 The return Statement................................................................................ 5-2
5.8 The format Statement .............................................................................. 5-2
5.9 The mwait Statement ............................................................................... 5-3
7 TSL Syntax
7.1 Syntax Specification ................................................................................ 7-1
8 SI System Calls
8.1 TIME ....................................................................................................... 8-2
8.1.1 Time Transactions ............................................................................... 8-2
8.1.2 Transaction for Get Time .................................................................... 8-3
8.1.3 Transactions for Date / Time Conversion ........................................... 8-4
8.1.4 Transactions for Current Time ............................................................ 8-5
8.2 WRITE..................................................................................................... 8-7
8.2.1 Write Transaction ................................................................................ 8-7
© 1996 - 2006 Teligent AB Id-008725 Rev A3
9 AC Loaded Libraries
9.1 Overview.................................................................................................. 9-1
9.1.1 High Level Application, AC_ and Low Level Application Interaction 9-
1
9.2 Initialization............................................................................................. 9-2
9.3 Function Entry Points .............................................................................. 9-3
9.4 Termination ............................................................................................. 9-3
9.5 Transactions............................................................................................. 9-4
9.5.1 Initiate a New Instance (Session) ........................................................ 9-5
9.5.2 Execute a Function .............................................................................. 9-5
9.5.3 Terminate a Session............................................................................. 9-5
9.5.4 Obtain a List of Active Sessions ......................................................... 9-6
© 1996 - 2006 Teligent AB Id-008725 Rev A3
1.1 Introduction
This document is an overview of the Transaction Script Language.
The implementation of a service implies selecting data and functions from what is available
in the system, and combining those using decision logic to apply data modifications or
execute functions. This is defined as a Work Flow Application (WFA) in the Teligent system.
To be able to run a WFA the scripts will be processed by a Script Interpreter, SI.
A WFA is constructed from a set of scripts, written in the Transaction Script Language (TSL).
TSL is a programming language designed for writing programs / applications that can be
executed on the Teligent P90/E System. The features of the TSL are as follows:
• TSL is a high level language with instructions for sending transactions and performing
simple data manipulation.
• TSL is both a compiled and interpreted language. TSL code is compiled to TSL byte-
codes, which are then executed by the SI - a TSL runtime environment in the Teligent
P90/E System.
2.1 Identifiers
An identifier consists of alphabetical characters, numbers and the character underscore (_).
The first character must be alphabetic.
Identifiers are used as
• variable names
• constant names
• transaction names
• labels
2.3 Comments
A comment is identified by an exclamation mark (!) and is terminated by a new line.
Comments are recognized anywhere in a program, except inside a character string. All
characters are allowed in the comment.
A variable that has no value is said to be ‘idle’. A variable is idle when it is first declared,
unless it has an initial value. A variable can become idle when it is in the response of a
transaction and the transaction is sent. If the FICS field associated with a variable in a
transaction response is missing, then the variable will change state to not idle after the
transaction returns and the variable will be set to either 0 or '\000' depending of variable type.
More examples:
Initialize length to 42
integer length 42;
Initialize the character char_name to ‘A’
character char_name 'A';
Allocate a 100 character long string and set it to ‘TEST’. Note the variable will be NULL-
terminated and test1.size = 5.
character test1[100] "TEST";
Allocate a 100 character long string and set it to 'TEST'. Note the variable will not be NULL-
terminated and test2.size = 4.
character test2[100] 'TEST';
Variables may not be initialized by another variable, only by numbers (integer) and strings
(character).
integer height;
character test3[100];
The height and test3 are idle, i.e. the value can be any value. It does not have to be a zero.
2.6 Arrays
2.6.1 Constant Array Declaration
A character array is defined in two ways - either within double quotes (”) or single quotes
('). Character strings within double quotes are NULL terminated while strings within single
quotes are not NULL terminated.
The character backslash (\) is treated as in C-style, i.e. if the following character is a lower
case letter of one of the following - a, b, f, n, r, t or v - it is a C escape sequence, such as \n
for newline. The backslash also allows octal and hex characters in the form \123 and \x3f.
Otherwise backslash quotes the following character, so that the following character or string
matches without the backslash. For example the string \hello will be treated as hello, and
the string “\“hello” \” will be treated as “hello”.
The length of a string is given by .size. The .maxsize operator gives the maximum size. The
maximum length of a character string is 2048 bytes.
Example:
character greeting[100] "Hello";
2.6.2 Format
The keyword format is used to assign a formatted string to a character buffer. The format
string is composed of characters and zero or more variable expansion specifications, i.e.
ordinary character (not $) is copied unchanged to the character buffer and each variable
expansion results in a replacement of the variable value.
Each variable replacement starts with a $ and is followed by the variable to replace.
An integer variable will be converted into a signed decimal notation.
In a character array variable will all the characters from the array be written to the output
character array variable.
A td_set variable will be converted to a comma separated list of transaction number included
in the set with the status represented by the letters "O" (outstanding) and "R" (received)
appended to each number.
Examples:
int x;
character message[100];
format message =: "Value of x is $x";
if x has the value 10 the character array message will contain the value [Value of x is 10\0].
Note the trailing \0 character.
character name[10];
character message[100];
format message =: 'Name of x is $name';
if name has the value Mr Smith, the character array message will contain the value [Name
of x is Mr Smith].
td_set t;
character message[100];
format message =: 'Transaction status $t';
if t contains transaction identifier 1,2 and 3 and the transaction number 2 has returned, the
character array message will contain the value [Transaction status 1O,2R,3O].
where expression1 and expression2 are expressions that evaluates to a positive integer
defining the start index and the end index. The second index must be larger or equal than
the start index.
They have the same precedence but it is lower then the arithmetic ones.
After them in precedence are the equality operators
= equality, compare equality
<> not equal
The precedence of these two operators is below the relation operators. By definition the
numeric value of an relation or logical expression is 1 if the relation is true and 0 if it is false.
As in C, all values that are not 0 are logical true.
2.11 Compare
The only relation operator for characters in TSL is cmp. The cmp instruction compares
byte strings;
buf1 cmp buf2
If the string buf1 is identical to the string buf2 the result is one (1), otherwise the result is
zero (0).
Example:
"ONE" cmp "ONE" equals 1
"ONE" cmp "TWO" equals 0
"abc" cmp "abc" equals 1
"abc" cmp ´abc´ equals 0 (the first operand is NULL terminated, and the second is
not)
Example:
If the transaction has the name "make_call" the parameter
"make_call.version" gives the version of the TPTF (transaction format).
3 FUNCTION
Chapter 3 Function
3-2
© 1996 - 2006 Teligent AB
Chapter 3 Function
3-3
© 1996 - 2006 Teligent AB
In the first call to func2, y has the value ‘a’. Inside the function this is changed to ‘x’ and
since this is an ‘inout’ parameter, the value of y is updated when the function returns. Also
the function returns the value ‘More Text’, which is copied into x.
In the second call to func2, x has the value ‘More Text’. Inside the function this is changed
to ‘This is an array of characters’, and since this is an ‘inout’ parameter, the value of x is
updated when the function returns. Also the function returns the value ‘More Text’, the first
character of which is copied into y. A runtime warning is produced since the data assigned
to y in this case is truncated.
Chapter 3 Function
3-4
© 1996 - 2006 Teligent AB
Chapter 3 Function
4-1
© 1996 - 2006 Teligent AB
4 TRANSACTIONS
Transactions are used for passing data between components or scripts. In TSL the response
from a transaction is used to assign a value to a variable. There are two ways a variable is
assigned a value from a transaction; either from the response of an outgoing transaction from
the script, or from the data field in the init transaction to a script.
For a complete description of the transactions for each component, refer
to the Component’s Reference Manual.
There are two types of transaction declarations in TSL: init and trns. The init declaration
is what the script receives at the start of the execution and the trns is declaration of transactions
sent from the script.
Chapter 4 Transactions
4-2
© 1996 - 2006 Teligent AB
4.1.3 To Function
The requested function and the destination component for the transaction must be declared
in the field tofunc, four characters each.
Example:
tofunc:comp,func;
4.1.6 Response
The data (variables) that are in the response from the transaction are declared in the field
response. The response field consists of a list of variables and the offset in the response
data-buffer or a list of variables and the FICS names. Each variable is separated by a comma
( ,).
Example:
response:var1=ANUMBER,var2=BNUMBER;
Chapter 4 Transactions
4-4
© 1996 - 2006 Teligent AB
Chapter 4 Transactions
5-1
© 1996 - 2006 Teligent AB
5 STATEMENTS
The Script Interpreter of TSL uses if-else logic to evaluate the different instructions in the
script. The statements that the Script Interpreter can evaluate besides ‘if’ are ‘send’, ‘wait’,
‘while’, ‘break’, ‘mwait’, ‘error’, ‘info’, ‘debug’, ‘log’, ‘format’, ‘call’, ‘return’ and ‘td
manipulation’.
Chapter 5 Statements
5-2
© 1996 - 2006 Teligent AB
Chapter 5 Statements
5-3
© 1996 - 2006 Teligent AB
7 TSL SYNTAX
APPLICATION := SCRIPTS+
DECLARATIONS := VARIABLE_DECLARATION*
CONSTANT_DECLARATION*
INIT_TRANSACTION_DECLARATION
TRANSACTION_DECLARATION*
FUNCTION_DECLARATION*
FICS_ARRAY =: <a comma separated list of FICS ended with semicolon “;”>
CODE_PAIRS := “;”
| CODE_PAIR “;”
SCRIPT_NAME := VARIABLE_NAME
| NULL_TERMINATED_STRING_LITERAL
COMPONENT := VARIABLE_NAME
| NULL_TERMINATED_STRING_LITERAL
FUNCTION := VARIABLE_NAME
| NULL_TERMINATED_STRING_LITERAL
VARIABLE_TYPE =: “IN”
| “OUT”
| “INOUT”
FUNCTION_BODY =: DECLARATIONS+
INSTRUCTIONS*
L_VALUE := VARIABLE_NAME
| VARIABLE_NAME “[“ EXPRESSION “]”
| VARIABLE_NAME “[“ EXPRESSION “..” EXPRESSION “]”
EXPRESSION := VALUE
| VALUE BINARY_OPERATOR VALUE
VALUE := L_VALUE
| NULL_TERMINATED_STRING_LITERAL
| STRING_LITERAL
| NUMERIC_VALUE
| BRACKETED_EXPRESSION
| UNARY_OPERATOR VALUE
BINARY_OPERATOR := “+”
| “-””
| “*”
| “/”
| “mod”
| “cmp”
| “=”
| “<>”
| “<“
| “>”
| “and”
| “or”
UNARY_OPERATOR := STRING_TO_NUMBER_OPERATOR
| NUMBER_TO_STRING_OPERATOR
STRING_TO_NUMBER_OPERATOR := “int”
NUMBER_TO_STRING_OPERATOR := “char”
INSTRUCTIONS := CONDITIONAL
| SEND
| WAIT
| MWAIT
| TD_ADD
| TD_RM
| TD_CLR
| ASSIGNMENT
| DEBUG
| BREAK
| LOG
| FUNCTION_CALL
| FORMAT
| RETURN
TEST := EXPRESSION
| “td_isset” “(“ VARIABLE_NAME” “,” VARIABLE_NAME “)” “;”
DEBUG := “SET_DEBUG_ON”
| “SET_DEBUG_OFF”
BREAK := “break”
RETURN := “return”
| “return EXPRESSION”
8 SI SYSTEM CALLS
The Script Intepreter, SI, supports some library functions that are accessible from the scripts.
The functions supported are TIME, WRITE, UTIL, RAND, SNMP and ACUT, each
described in this chapter.
The interface to these functions is a transaction with the type field not set and the component
in the tofunc field set to one of the supported library functions, e.g. ‘TIME’. Below is an
example of a transaction that will access the TIME function.
trns time
{
type:;
tofunc:"TIME","";
retfunc:;
senddata:
timefunc="TIMEFUNC";
response:
;
}
These transactions are processed locally in the SI and therefore no transaction number,
issuestamp or timestamp is set in the transaction. The only tptf member that is updated is
the cc and reason codes.
Note that scripts cannot be named like these functions, since the functions are accessed in
the same way as a local script.
8.1 TIME
Three different times that represent the same time exist on a Teligent P90/E system.
• Universal Coordinated Time (UTC)
The computer's hardware clock must be set to this time. It is normally set and updated
automatically from a time server.
• The installed time zone for the operating system
This is the time displayed by the operating system when using the command ‘date’. This
is normally set during installation of the operating system.
• P90 system time
The time zone for all Teligent P90/E components, configured in tm.cfg and in the daemon
configuration files (e.g. tpd, dmm and a2s).
Time can be read in tsl applications as well as directly in the Unix environment. The time
is changed during daylight saving time (summer / winter time). The time zone (TZ) variable
defines the time change. This is set in the configuration files; tm.cfg.
Different time in time zones can be calculated using own time zone variables, if the scripts
have to present a time in a specified time zone. The time is presented correct for the zone
as well as daylight saving time during summer.
Note:
• Timestamp should be used for all calculations. Time should not be used
with time zone as it will cause problems at time change during summer
/ winter change.
• Timestamp should be used for all storage of time and date in database.
• Time functions with time zone variable should be used when presenta-
tion of time is made.
Local date and time in epoch: Current timestamp, date and time calcu-
TIMEFUNC = LDTE lated by TZ:
FICS Arguments: TIMEFUNC = SDTE
None FICS Arguments:
Return FICS: TIMEZONE
TIMESTAMP Return FICS:
TIMESTAMP
Current timestamp, UTC date and time Compatible, use the ‘old’ function
in epoch:
TIMEFUNC = CDTE
FICS Arguments:
None
Return FICS:
TIMESTAMP
Local date in epoch: Current timestamp, date calculated by
TIMEFUNC = LDAE TZ:
FICS Arguments: TIMEFUNC = SDAE
None FICS Arguments:
Return FICS: TIMEZONE
TIMESTAMP Return FICS:
TIMESTAMP
Current timestamp, UTC date in epoch: Compatible, use the ‘old’ function
TIMEFUNC = CDAE
FICS Arguments:
None
Return FICS:
TIMESTAMP
Local time in epoch: Current timestamp, time calculated by
TIMEFUNC = LTIE TZ:
FICS Arguments: TIMEFUNC = STIE
None FICS Arguments:
Return FICS: TIMEZONE
TIMESTAMP Return FICS:
TIMESTAMP
Current timestamp, UTC date in epoch: Compatible, use the ‘old’ function
TIMEFUNC = CDAE
FICS Arguments:
None
Return FICS:
TIMESTAMP
8.2 WRITE
Note: This function is not used in Teligent P90/E version 1.6 and later.
The UTIL function type WRITEFILE described in paragraph 8.3.3 should be
used instead.
This function is used to write data to a file on the node where the SI is executed.
Example:
trns write_file
{
type:;
tofunc:"WRITE","";
retfunc:;
senddata:
"/tmp/file.txt" = "PATH"
"Hello World" = "BUF"
"5" = "SIZE"
"whatever" = "APPEND"
"whatever" = "NEWLINE"
response:;
}
In this example the transaction appends ‘Hello’, i.e. the first five characters in BUF, to the
file /tmp/file.txt. A newline is added in the file after ‘Hello’.
8.3 UTIL
The UTIL function contains four different function types; DATABASE, READFILE,
WRITEFILE and VOXFIDX. The function types requires a FICS ‘UTILTYPE’, which
specifies the function to use.
Return FICS:
READDATA The text that was read from the file at the requested position.
NEWFILEPOS The first position after the read text in the file (i.e. where the
reading was stopped).
trns AC_read_file
{
type:;
tofunc:"UTIL","";
retfunc:;
senddata:
"READFILE" = "UTILTYPE",
"etc/motd" = "FILE",
"0" = "FILEPOS",
response:
new_pos = "NEWFILEPOS",
buf = "READDATA";
}
Information stored in index files is stripped out from any white space delimeter when being
accessed (" ", "\t" and "\n").
The type "string" will skip the character stripping. String message may have the ";" character
in its text, provided it was stored in the form "\;" (in order to distinguish it from the end of
the index delimeter).
The FICS arguments for this function are
VOXFILE The name of file with index definitions
DATA1 The data which will generate index string.
Return FICS:
VOXIDX The index string
IDXLEN The length of the index string
8.4 RAND
This function will generate a random number returned in the FICS DATA in the range 0 to
the range specified in the FICS RANGE.
Example:
integer range;
integer random;
trns rand
{
type:;
tofunc:"RAND","";
retfunc:;
senddata:
range = "RANGE";
response:
random = "DATA";
}
Return FICS:
DATA The generated random number in the range 0 to range <specified
in the input FICS RANGE>.
8.5 SNMP
the SNMP function will send a TPTF-transaction from the SI to the a2s daemon. The a2s
daemon will translate the TPTF transaction into an SNMP trap and set instruction.
8.6 ACUT
ACUT is the library interface to local database files within the AC_ and ALH that executes
the script.
Example:
trns opendb
{
type:;
tofunc:"ACUT",""
retfunc:;
senddata:
"INSERT"= "FUNC",
"dbname"= "TABLE",
"primkey"= "PRIMKEY",
"data1"= "DATA1";
response:
}
Create a key and write data to the key. Write data to the key in the database.
(The default behaviour of the insert rou- (The default behaviour of the write rou-
tines is to fail if the key already exists in tines is to enter new key/data pair,
the table): replace any previously existing key):
FUNC = INSERT FUNC = WRITE
FICS Arguments: FICS Arguments:
TABLE TABLE
PRIMKEY PRIMKEY
[DATAn] [DATAn]
Return FICS: Return FICS:
DATAn DATAn
Get next entry in database. If the key is Get previous entry in database. If the key
not set the first key will be returned: is not set the last key will be returned:
FUNC = GETN FUNC = GETP
FICS Arguments: FICS Arguments:
TABLE TABLE
[PRIMKEY] [PRIMKEY]
Return FICS: Return FICS:
PRIMKEY PRIMKEY
Delete an entry from database: Delete the table. This will remove the
FUNC = DELETE table and its underlaying files from the
FICS Arguments: disk:
TABLE FUNC = RMTABLE
PRIMKEY FICS Arguments:
Return FICS: TABLE
None Return FICS:
None
Update an entry in the database (This Unload the table. The table and its
function will update an entry in the data- underlaying files are still on the disk and
base only if the data in VERIFY FICS is can be reloaded later:
exactly the same as in the entry. If not, FUNC = UNLOAD_TABLE
the DATAn FICS will be updated with FICS Arguments:
the current value): TABLE
FUNC = VERIFY_UPDATE Return FICS:
FICS Arguments: None
TABLE
PRIMKEY
VERIFY
[DATAn]
Return FICS:
DATAn
9 AC LOADED LIBRARIES
9.1 Overview
The purpose of the AC loaded library is to provide the application programmer with a set
of run time libraries or functions to use in applications. In effect it enables the Teligent P90/
E with a set of DLL's that a product can use in real-time. These libraries (written in TSL)
will provide all the low level and complex functionality needed. The application programmer
can then concentrate on building the application at a higher level of abstraction. Furthermore
it will provide a mechanism to rapidly port complex products such as UM to Application
Builder or any similar environment.
The high level application is the actual call flow and the low level application (or DLL-
application) provides the core functions of the service.
The concept behind AC Loaded Libraries is to:
1. Provide rapid porting of current products to Application Builder.
2. To give the Teligent P90/E and its products an extensive set of run time libraries that
can be accessed by another application.
3. To protect the application programmer from having to perform complex tasks in
Application Builder, i.e. these tasks exist in the loaded libraries, not the controlling
application).
4. To provide better resource management.
5. To provide better control of the state of an application within the platform.
6. Functions in the loaded library may become modules that can easily be built into
Application Builder.
The high level application (or controlling application) contains the actual ‘call flow’. This
may be written in Application Builder.
The low level application is the loaded library and contains the low level modules and/or
functions. Only one low level application may be owned by each high level application. The
low level application is usually written in TSL.
The AC_ is the interface between the high level and the low level application. It will forward
requests from the high level application to the correct instance of a low level application.
Transactions passed between the two are AC_ internal transactions. The low level application
and the corresponding high level application will be on the same AC_.
Note that the low level application and the corresponding high level application(s) must be
on the same AC_ component. A definition file should be used to load the low level
application(s) upon AC_ startup.
To use the resources of a low level application instance the following transaction flow must
occur in the high level application:
1. TPTFTYPE = LIB / TOFUNC = INIT
Initialise a low level application instance (session)
2. TPTFTYPE = LIB / TOFUNC = Four (4) character function name
Execute a single function
3. TPTFTYPE = LIB / TOFUNC = TERM
Terminate the low level instance when the high level application ends.
9.2 Initialization
As the controlling application starts it will submit one or more initialization transactions
back to the owning AC_ (with tptf type = LIB and tofunc = INIT). These transactions are
‘internal’ AC_ transactions. Upon receipt of the INIT transaction the AC_ will start the
particular low level application on one of its free Si’s. The low level application and the
associated session will exist until either terminated by the high level application or until the
low level application has terminated.
When the low level application has been initialized it will need to decrement the allocatable
counter by 1. It is necessary to place a limit on only one (1) low level application per
controlling script.
9.4 Termination
When a high level application terminates the low level application associated with that will
also be terminated.
However, control of the low level application can be passed from high level application to
high level application (or Si to Si). This is achieved by the application emitting an AC_
EXEC transaction with the tptf type set to LIB. The AC_ will internally transfer ownership
of the low level application to the new instance of the high level application. This behaviour
is not permitted with an AC_ REXC transaction.
The low level application can if desired be terminated by the high level application by sending
an internal TERM transaction, with the tptf type set to LIB.
Refer to paragraph 9.5 for more information of the transactions.
9.5 Transactions
The following FICS is required/returned:
EXECNAME The name of the script to execute when the BEGN transaction is
sent.
Format: alpha numeric
VERSION The version of the script to execute.
Format: alphanumeric
APPL The application ID of the script to execute.
Format: alpha numeric
SESSION Identifies a single instance of a low level application. This will
be sued by the high level application when sending all transac-
tions to that instance.
Format: numeric (integer)
SESSLIST Returns a comma delimited list of all sessions active.
Format: alpha numeric
LIFESPAN Returns information of how long a specified session has been
active.
Format: numeric (seconds)
The following reason codes are common for all functions described in this paragraph except
for STTS:
0 OK
1 The application does not exist
2 AC_ out of resources
4 The application exists
5 Input data is missing in the transaction
6 Wrong path or the path does not contain the script