String formatting
Kun slutbruger-hjælpen er for tiden oversat til dansk. Hjælp til installation og administration af Zylinc-løsninger er for tiden på engelsk.
Dette emne er fortrinsvis for administratorer og/eller folk som bestyrer en Zylinc-løsning
String formatting is a way to convert differently formatted phone numbers into a common format, so that they'll appear consistently on people's screens, and so that they'll work consistently when you make outgoing calls.
Such re-formatting into a common format is also called normalization, and you can read a short description of how it works in Specify number plan settings. This topic, however, goes into much more depth about the special normalization method, called string formatting, that was used in earlier Zylinc versions.
String formatting can, for example, be used to:
-
Add a missing prefix, followed by a default country code, to external numbers if the user didn’t enter them. For example, if you call 12345678, string formatting can transform that number into +45 1234 5678.
- Remove unwanted characters, for example ( ) and spaces.
- Add new spaces at specified positions to make numbers more readable on the screen. For example, string formatting can transform 12345678 into 12 34 56 78.
In very few advanced scenarios, string formatting can also be useful when you need to route specific phone number patterns to separate SIP trunks, when you initiate outgoing calls from ZyDesk.

String formatting is very similar to Specify number plan settings.
We recommend that you handle number normalization through number plan settings, because it works for all client types across the entire Zylinc solution.
The string formatting language was developed by Zylinc as a simple version of the programming language C. Because the name of the developer behind the string formatting language began with a T, it got the name Tscript.
String formatting only works in ZyDesk clients, like Zylinc Attendant Console, Contact Center, Team Center (previously known as Employee Assistant or Operator), and Service Center. ZyDesk clients are the only parts of the Zylinc solution that understand and use Tscript and the concept of string formatting.
That's why string formatting has now been deprecated; it's still a way to normalize phone numbers, but there's not going to be any further development on it, and we're looking into better alternatives.

Most of the time, string formatting will simply add a specified prefix, for example 00 or +, followed by a default county code, for example 45, to phone numbers that are equal to or shorter than the short number length specified in the Administration Portal.
String formatting also strips special characters from numbers, for example ( ) and space, and then inserts new spaces in pre-specified positions, for example:
- 88336645 becomes +45 8833 6645
- 12 (3) 4 becomes 1234, because that number is shorter than or equal to the specified short number length
The special characters are stripped before number length is evaluated, and the length of the stripped number is then compared to the specified short number length. Because of that, for example ( ) and space don’t count as a part of the number length.

-
If, then, else:
if #predicate
{
}
else
{
}
You can omit else and { } for the else block.
#predicate examples (4 and foo are sample values):
- Is number
- begins with 'foo'
- begins not with 'foo'
- length equals 4
- length not equals 4
- length greater than 4
- length less than 4
- @define: Definition of a general macro that can be used across scripts
- @include: Includes an already defined macro in the given script
- // Comment: You can use // to make comments within the code
- remove all 'X': Removes all instances of X in the string
- prefix 'Y': Adds Y in front of the string
-
substring index Y: Removes Y characters from start of string
- replace begin X with Y: If the string starts with X, replace it with Y
- replace begin Z with '': If the string starts with Z, remove the Z
-
replace begin '(??)' with '00??' using '?‘: Remove ( and ), but keep ?? and prefix 00
Example: (45) 12345678 will become 0045 12345678
-
replace begin '(??)' with concat @landcode_prefix '??' using '?': Remove ( and ), but keep ??, and prefix the contents with the variable @landcode_prefix.
Example: (45) 12345678 will become 0045 12345678
- format 'xxx xx xx' using 'x': format the string this way, for example 123 45 67

If you're going to use Zylinc client types that don't support string formatting, for example Mobile Agent/Operator, it's important to know if Tscripts have been changed compared with the default Tscripts that were shipped as a part of release 5.2, 5.5, 6.0, or 6.5.
The default scripts that were shipped as a part of those releases don't add or remove specific prefixes from phone numbers, except for the default behavior that you can set up in the Administration Portal, when you select SYSTEM > User Directory and go to the Numberplan Settings section. For more information, see Specify number plan settings
If you know that Tscripts weren't changed, you can use the client types that don't support string formatting without the need to make any changes to the route pattern or voice route on your PBX.
To find out if Tscripts have been customized, do the following:
-
In the SQL Server Management Studio menu, select Tools > Options
-
Expand Query Results > SQL Server, and select Results to Text
-
In Maximum number of characters displayed in each column enter 8192
-
Click OK
-
Restart SQL Server Management Studio
-
Click New Query
-
Press CTRL+T to activate Results to text
-
Copy the following SQL code to the query window, and replace ZyDB in the first line with the name of your ZyDB:
SQL_script_to_extract_all_string_formatting_code_from_all_profiles.txt
-
Press F5 to run the script
If your Tscripts haven't been changed: You'll see the message 0 Tscripts have been changed, compared to the Tscripts that were shipped as a part of release 5.2 or 5.5 or 6.0 or 6.5
If one or more Tscripts have been changed: The counter will show a value greater than 0, and you'll also see:
- Information about which of the Tscripts that have been changed, and the user, profile, or database level that the changes have been activated for
- The source code of the changed Tscript
If you need to compare the source code of the changed script with the source code of the default script that shipped with your release, you can copy the code to a text file and use a file comparison tool. To get text files that contain the original code see: Default Tscript code

If you remove specific digits, that correspond to a number series that belong to your organization (in this example: 88336), from the beginning of external phone numbers, your Tscript may look like the following:
if length greater than @internal_length
{
if begins with '88336'
{
// remove first six digits
substring index 5
}
}

In the ZyDB database, Tscripts scripts don’t exist in clear text. All scripts are base64-encoded.
However, you can extract all string formatting scripts from a ZyDB database, and decode the base64 format. This is useful if you want to copy all of your organization's scripts to a text file. You can then compare that text file with a similar file made from a clean database, and find out if somebody has changed the default scripts.
-
In the SQL Server Management Studio menu, select Tools > Options
-
Expand Query Results > SQL Server, and select Results to Text
-
In Maximum number of characters displayed in each column enter 8192
-
Click OK
-
Restart SQL Server Management Studio
-
Click New Query
-
Press CTRL+T to activate Results to text
-
Copy the following SQL code to the query window, and replace ZyDB in the first line with the name of your ZyDB:
SQL_script_to_extract_all_string_formatting_code_from_all_profiles.txt
-
In the SQL script, locate the following two lines :
--If you need to display the code of all scripts, even if they have not been changed, compared to the default scripts shipped, uncomment the following line
--delete from #mytemp_wellknown_tscriptsRemove the two -- before the delete command, so that the delete command becomes un-commented. The two lines should then look similar to:
--If you need to display the code of all scripts, even if they have not been changed, compared to the default scripts shipped, uncomment the following line
delete from #mytemp_wellknown_tscripts -
Press F5 to run the script
In the results window, you can now view all Tscript code for all the string formatting scripts.
To find text files made from a clean database, see Default Tscript code

If you need to restore default settings, or to compare your scripts against the default, you can find the source code here:
Files within the ZIP file contain default string formatting extracted from release 6.0u4.20:
-
Release_6.x_all_profiles.txt
-
Release_6.x_Attendant_Console_6.0_only.txt
-
Release_6.x_Contact_Center_6.0_only.txt
-
Release_6.x_Operator_6.0_only.txt
-
Release_6.x_Operator_6.0_BroadWorks_only.txt
-
Release_6.x_Service_Center_6.0_only.txt
-
Release_6.x_Time_6.0_only.txt
You can extract your own, and then compare the contents of your string formatters against the default, see Extract string formatting scripts from SQL Management Studio

Some parts of ZyDesk settings displays string formatting script contents as base64. It looks encrypted.
To see Tscripts as clear text, in ZyDesk, click on the base64 encoded string. This will open Tscript editor.
In Tscript editor, you can:
- Display or edit the script in clear text.
- Enter number examples to test scripts.
- If a script contains errors, you can see error descriptions in Tscript editor.
For more information, see Use Tscript editor efficiently in ZyDesk

The following is useful tricks when you need to:
-
Change or update existing scripts
-
Develop new scripts
-
Find out what each line of code does
-
Enter phone numbers to view how string formatting changes those numbers

-
Make a backup of the contents of Switch (CC) DDE Lookup formatting. Typically, this script contains only one line of code: include @initial_formatting. You're going to use that script as a debugger and development tool, and when you are done, you can just restore the backup.
-
Make a screenshot of General environment variables, and manually type the following into Notepad:
define string @landcode='45'
define string @landcode_prefix ='+'
define int @internal_length = 7
define string @external_prefix='0'
-
Make a screenshot of Switch Environment vars, and manually type the following intoNotepad, after the code from the previous step
define string @internalsiptrunk = 'newTrunk'
define string @externalsiptrunk = 'newTrunk'
define string @internalprefix = ''
define string @externalprefix = ''
-
Copy the code from Notepad into Switch (CC) DDE Lookup formatting, so that the original content that you backed up is replaced.
-
Double-click the Tscript editor window title bar to maximize the window
You can now override all the variables that ZyDesk gets from the Administration Portal, without the need to make changes in the Administration Portal, and without the need to restart ZyDesk for the changes to take effect.

Now that you can edit all the variables imported from the Administration Portal, without opening the portal and without the need to restart ZyDesk, you can make a copy of the active code lines within the macros in Environment Scripts
-
Open Environment Scripts
-
Make a copy of the Tscript code, and paste the code into Notepad.
-
Remove the lines that define the macros, and the outermost set of { and } that refers to each macro definition.
For example:
-
Remove the line: define macro @initial_formatting
-
Remove the { immediately after the define macro @initial_formatting command
-
Remove the } immediately before the next macro definition (or the end of the file)
-
Remove the line: define macro @set_prefixes
-
Remove the { immediately after the define macro @set_prefixes
-
Remove the } at the very bottom of the file.
-
-
Now, go to Switch (CC) DDE Lookup formatting and insert that code from Notepad after the eight lines that contain the variable definitions.
For the default scripts for the Service Center 6.0 profile, it should look like this:
define string @landcode='45'
define string @landcode_prefix ='+'
define int @internal_length = 7
define string @external_prefix='0'
define string @internalsiptrunk = 'newTrunk'
define string @externalsiptrunk = 'newTrunk'
define string @internalprefix = ''
define string @externalprefix = ''
remove all ' '
replace begin '(??)' with concat @landcode_prefix '??' using '?'
replace begin '(+??)' with concat @landcode_prefix '??' using '?'
replace begin '(00??)' with concat @landcode_prefix '??' using '?'
replace begin '+' with @landcode_prefix
replace begin '00' with @landcode_prefix
remove all '('
remove all ')'
if is number
{
if length greater than @internal_length
{
// begins with '000'
if begins with concat @external_prefix @landcode_prefix
{
// remove first '0'
replace begin @external_prefix with ''
}
// not '00'
if begins not with @landcode_prefix
{
// '0'
if begins with @external_prefix
{
replace begin @external_prefix with ''
}
prefix @landcode
prefix @landcode_prefix
}
}
}
Now you can use Tscript editor as a debugger, for example:
- In Test, you can enter the number to test, and you can view the normalized number.
- To work on one line of code at a time, simply add // to the beginning of all lines except the one that you want to work on. (// indicates a comment.) You can work through the predefined macros, one line at a time, to understand the purpose of each line.
- You can change variable values directly in the Tscript editor, without the need to go through cycles of Administration Portal changes and ZyDesk restarts.


The string formatting code is very similar across the ZyDesk profiles. However, ...
- Some scripts are only relevant in Team Center (previously known as Employee Assistant or Operator)
- Other scripts are only relevant in Attendant Console, Contact Center, and Service Center
- Some scripts are relevant in all profiles
- String formatting settings can be shared across different ZyDesk profiles, or you can set up specific scripts for different ZyDesk profiles. See Manage settings in ZyDesk clients.

Tscript name (in ZyDesk settings GUI) | ZyDB key | Editable? | Available in Attendant Console, Contact Center, Service Center? | Available in Team Center (previously Employee Assistant or Operator)? | M1) | M2) |
---|---|---|---|---|---|---|
Global environment > General environment variables | Not stored in ZyDB | In Administration Portal | Yes | Yes | ||
Global environment > Environment scripts | 1494 | Yes | Yes | Yes | ||
Formatters > Phone number - database | 1493 | Yes | Yes | Yes | Yes | Yes |
Formatters > Phone number - active | 1497 | Yes | Yes | Yes | Yes | Yes |
Formatters > Phone number - gantt | 1491 | Yes | Yes | Yes | Yes | Yes |
Formatters > Outgoing number prefix | 1492 | Yes | Yes | Yes | Yes | Yes |
Switch Global environment > Switch Environment vars | Not stored in ZyDB | In Administration Portal | Yes | |||
Switch Formatters > Switch Extension Strip | 1496 | Yes | Yes | Attendant Console
Contact Center Service Center |
Contact Center | |
Switch Formatters > Switch (CC) Extension Formatting | 1498 | Yes | Yes | Attendant Console
Contact Center Service Center |
||
Switch Formatters > Switch Siptrunk|Extension formatting | 1495 | Yes | Yes | Attendant Console
Contact Center Service Center |
Attendant Console
Contact Center Service Center |
|
Switch Formatters > Switch (CC) DDE Lookup Formatting | 1499 | Yes | Yes | Attendant Console
Contact Center Service Center |
M1) Script includes macro 1: include @initial_formatting
M2) Script includes macro 2: include @set_prefixes

This Tscript assigns numberplan settings from the Zylinc Administration Portal to global Tscript variables.
You can’t make changes to this script, but you can change your numberplan settings, or overwrite the variables locally within any other Tscript.
To view or change numberplan settings in the Administration Portal:
-
In the Administration Portal menu, select SYSTEM > User Directory
-
In the Numberplan Settings section, you can view or change the following settings:
Administration Portal numberplan settings | Tscript variable name |
---|---|
Shortnumber length | @internal_length |
Default Country Code | @landcode |
Prefix | @landcode_prefix |
External Line Prefix | @external_prefix |
If you need to use other values than those defined in the Administration Portal, you can overwrite the variables.
To overwrite the variables, insert some or all of the following lines in the top of any string formatting script, and replace the variable values with the values that you need to overwrite.
define string @landcode='358'
define string @landcode_prefix ='00'
define int @internal_length = 5
define string @external_prefix='0'

This Tscript assigns SIP Trunk Settings from the Zylinc Administration Portal to global Tscript variables.
In the Administration Portal menu, select SYSTEM > SIP Trunks and click SETTINGS
-
@internalsiptrunk: Name of the internal/default SIP trunk
-
@externalsiptrunk: Name of the external SIP trunk
-
@internalprefix: Prefix to add for calls routed via the internal/default SIP trunk
-
@external_prefix: Prefix to add for calls routed via the external SIP trunk
You can overwrite the variables in the same way as for General environment variables
define string @internalsiptrunk = 'newTrunk'
define string @externalsiptrunk = 'newTrunk'
define string @internalprefix = ''
define string @externalprefix = ''

This Tscript defines two standard macros that many of the other Tscripts make use of. You can also make your own macros and refer to them from other Tscripts.

-
Removes all spaces
-
May incorrectly format numbers that begin with the character (. For example, (45)12345678 may wrongly be formatted to +4412345678. For more information see Avoid string formatting of numbers that begin with (.
-
If number begins with +, replace the + with @landcode_prefix (which is often a +)
-
If number begins with 00, replace the 00 with @landcode_prefix (which is often a +)
-
Removes all (
-
Removes all )

Number |
@inital_formatting prefix= + output |
---|---|
1 |
1 |
12 |
12 |
1234 |
1234 |
12345678 |
12345678 |
1234567890 |
1234567890 |
+1 |
+1 |
+12 |
+12 |
+1234 |
+1234 |
+12345678 |
+12345678 |
+1234567890 |
+1234567890 |
001 |
+1 |
0012 |
+12 |
0012345678 |
+12345678 |
001234567890 |
+1234567890 |
00 1 23 (4) 567 890 |
+1234567890 |
(98)12345678 |
+9912345678 See note |
(89)12345678 |
+8812345678 See note |
(+98)12345678 |
+9912345678 See note |
(0098)12345678 |
+9912345678 See note |
Note: The second digit is wrongly transformed into the same value as the first digit. You should avoid using or importing any numbers where the first character is a ( and the fourth and sixth characters are a ).

Number |
@inital_formatting prefix = 00 output |
---|---|
1 |
1 |
12 |
12 |
1234 |
1234 |
12345678 |
12345678 |
1234567890 |
1234567890 |
+1 |
001 |
+12 |
0012 |
+1234 |
001234 |
+12345678 |
0012345678 |
+1234567890 |
001234567890 |
+1 23 (4) 567 890 |
001234567890 |
001 |
001 |
0012 |
0012 |
001234 |
001234 |
0012345678 |
0012345678 |
001234567890 |
001234567890 |
00 1 23 (4) 567 890 |
001234567890 |
(98)12345678 |
009912345678 See note |
(89)12345678 |
008812345678 See note |
(+98)12345678 |
009912345678 See note |
(0098)12345678 |
009912345678 See note |
Note: The second digit is wrongly transformed into the same value as the first digit. You should avoid using or importing any numbers where the first character is a ( and the fourth and sixth characters are a ).

If the number only contains the digits 0...9 and is longer than the specified shortnumber length specified in the Administration Portal numberplan settings, remove one of the leading zeros, and add the prefix and the country code.

Number |
@set_prefixes output prefix = + Shortnumber length = 7 Default country code = 45 |
---|---|
1 | 1 |
12 | 12 |
1234567 | 1234567 |
12345678 | +4512345678 |
1234567890 | +451234567890 |
01234567 | +451234567 |
00123456 | +450123456 |
00012345 | +450012345 |

Number |
@set_prefixes output prefix = 00 Shortnumber length = 7 Default country code = 45 |
---|---|
1 | 1 |
12 | 12 |
1234567 | 1234567 |
12345678 | 004512345678 |
1234567890 | 00451234567890 |
01234567 | 00451234567 |
00123456 | 00123456 |
00012345 | 0012345 |

Formats numbers before database lookup, for example ZyCore ID.

Formats numbers before ZyDesk clients display them for active calls.

Formats numbers before ZyDesk clients display them in the Time overview.

Formats numbers that you enter in the dial field of a ZyDesk client. Useful if you need to add breakout prefixes.

For outgoing calls made in Contact Center, but not in Team Center (previously known as Employee Assistant or Operator). Numbers are formatted before they're dialed.

Tscript name (in ZyDesk settings GUI) | Attendant Console | Contact Center | Service Center | Team Center (previously Employee Assistant or Operator) | Team Center (previously Employee Assistant or Operator) for BroadWorks | Time |
---|---|---|---|---|---|---|
Global environment > General environment variables | ||||||
Global environment > Environment scripts | ||||||
Formatters > Phone number - database | ||||||
Formatters > Phone number - active | 1) | 2) | 1) | 1) | 1) | 1) |
Formatters > Phone number - gantt | 1) | 2) | 1) | 1) | 1) | 1) |
Formatters > Outgoing number prefix | 3) | 4) | 3) | 3) | 3) | 3) |
Switch Global environment > Switch Environment vars | ||||||
Switch Formatters > Switch Extension Strip | 5) | 6) | 5) | N/a | N/a | N/a |
Switch Formatters > Switch (CC) Extension Formatting | N/a | N/a | N/a | |||
Switch Formatters > Switch Siptrunk|Extension formatting | N/a | N/a | N/a | |||
Switch Formatters > Switch (CC) DDE Lookup Formatting | N/a | N/a | N/a |
Notes about the differences:
-
Scripts where the only difference is, for example, spaces or line spaces are considered identical. The functionality is the same even though the base64 values are not identical.
-
Across all profiles, Formatters > Phone number – active and Formatters > Phone number – gantt differ in one line in the Contact Center profile:
1) line 13 = format 'xxx xxxx xxxx xxxx' using 'x'
2) line 13 = format 'xxx xx xx xx xx xx xx' using 'x'
-
Across all profiles, Formatters > Outgoing number prefix differs in one line in the Contact Center profile:
3) line 10 missing
4) line 10 = prefix @external_prefix
-
Across Attendant Console, Contact Center, and Service Center profiles, Switch Formatters > Switch Extension Strip differs in one line in the Contact Center profile:
5) line 2 missing
6) line 2 = include @set_prefixes
Team Center (previously known as Employee Assistant or Operator), Team Center (previously Employee Assistant or Operator) for BroadWorks, and Time profiles don’t include this script.

A bug prevents correct handling of some numbers that begin with (, if, for example, the fourth, fifth, or sixth character is a ).
It affects the macro @initial_formatting, which is included in almost all Tscripts:
- replace begin '(??)' with concat @landcode_prefix '??' using '?'
- replace begin '(+??)' with concat @landcode_prefix '??' using '?'
- replace begin '(00??)' with concat @landcode_prefix '??' using '?'
For example, (45) or (+45) or (0045) is formatted into +44 instead of +45 as expected. The first character of the specified default country code is correct, but the second character is a copy of the first character, and not the correct second character as expected.

ZyDesk profiles together with string formatting lets you:
-
Use different string formatting for each ZyDesk profile, or make all profiles share the same string formatting. See Manage settings in ZyDesk clients.
-
For ZyDesk profiles, you can redefine the eight variables that are normally specified in the Administration Portal and shared between all profiles. To do this, simply include the eight lines (or some of them) to the top of the string formatting scripts where you need them. See Override system-defined variables from Administration Portal with locally defined variables.

- In the Administration Portal menu, select INSTALL > Portal Configuration, and make sure that SIP trunks is selected.
- In the Administration Portal menu, select SYSTEM > SIP Trunks, and in the top-right corner, click SETTINGS.
You’ll see a Use String Formatting option there.
If an outgoing call is made from a ZyDesk client, string formatting can add a | (pipe) character followed by a SIP trunk name (or the word internal or external) to the phone number. The information after the pipe character tells the Zylinc Queue Manager which SIP trunk to use for the outgoing call, based on for example, a number pattern in the beginning the phone number.
Alternatively, the system will use the specified External SIP trunk for numbers that are longer than the specified short number length, and the specified Internal SIP trunk for numbers that are equal to or shorter than the specified short number length.
If you call special external numbers, like 114 or 1813, it's entirely up to the internal SIP trunk to decide how to route such numbers. You may have an internal phone with, for example, the number 1813, but we don’t recommend using such numbers internally.
In many cases, a single SIP trunk covers both internal and external calls.
The concept of adding a | (pipe) character to the phone number that you're going to call will work, if you initiate the calls from:
-
ZyDesk running as Attendant Console profile
-
ZyDesk running as Contact Center profile
-
ZyDesk running as Service Center profile
It doesn’t work for Team Center (previously known as Employee Assistant or Operator) profiles, or other client types, for example Mobile Agent/Operator, because they don't use an outgoing SIP trunk for making outgoing calls. Instead, they simply instruct the phone device or softphone to call the entered number.
Dette er hjælp til Zylinc version 6.5. Du kan vælge hjælp til andre versioner her.
© 2021 Zylinc A/S • Ansvarsfraskrivelse
Zylinc unified help har vundet UK Technical Communication Awards
Hjælpeversion: 24 februar 2021 15:41:38
Del denne side med andre: