help • 3 The Graphical Script Editor • Variables and System Functions
3.5 Variables and System Functions
As a fundamentally new property in comparison to the Rule Wizard of the Call Routing Managers, the Graphical Script Editor provides the option of using variables and system functions. Its contents are defined during the execution of the script and are only valid during this run (e.g. time of the call). These functions will help you to make decisions based on current information or to forward current information.
A differentiation is made between user-defined variables and system functions.
User-Defined Variables
The block "Set Variable" can be used to set user-defined variables.
* 
The name of the variable may contain the characters A-Z, a-z, 0-9 and _ (underscore). The variable name must begin with a letter.
 
A variable can contain a sequence of characters (string) or a numeric value. You can define the contents of a variable and in doing so you can also use system functions. In addition, a variable can be an expression from existing variables or system functions.
Alternatively, the caller can make an entry during the script procedure that are stored in a variable (e.g. with the block "Get DTMF" or "Get DTMF String").
You can always use the symbol to list and use previously defined variables. The variables can be used for evaluation, e.g. in the blocks "Evaluate variable" or "Announcement selection", or in the blocks "Voice Box", "Announce string", "Put through", "Loop", "FollowMe" and "Send e-mail" etc.
* 
It is not permitted to use a variable name, which is identical to the name of a system function.
 
Use of Variables
If you would like to use a variable or a system function in a script, begin the entry in this window with the equal sign (=). This will indicate to the the Graphical Script Editor that the following text is an expression, which consists of individual character sequences and variables. This expression will then be analyzed when the Graphical Script Editor is running. If there is no equal sign at the beginning of the entry window, the contents of the entry field will only be interpreted as a string by the Graphical Script Editor.
Example:
You would like to forward a call to an number that is mathematically the result of the number called (CalledNumber()) called.
To do this, open the "Properties of Connect" page of the block "Connect". Now enter in the "Connect call for xx seconds" field the expression
=CalledNumber() + 100
and then the caller will then be redirected to number ‘334’ when he dials the extension ‘234’.
* 
If you mistakenly enter only "CalledNumber() + 100" (without an equal sign =), this will lead to a misconnection.
 
Analysis of Variables in Expressions
If you would like to analyze a variable or system function (e.g. in the blocks "Evaluate" or "Choose Announcement", you can compare a variable with an expression.
This expression can contain all the user-defined variables of this script as well as all system functions. The expressions used here are created in the syntax of Visual Basic Script:
*A variable can be either a sequence of characters ("3") or a numeric value (3).
*It is possible to link variables.
The expression
="Call from the number" & CallerNumber()
during the call handling of a call from the number 0123456789, will result in
Call from the number 123456789
*Calculation operation with variables
The expression
a=3*b
will be numerically evaluated so that a will be assigned the result of the calculation operation. This requires that b contains a numeric value or a string, which is interpretable as a numeric value.
*Addition
This operation is executed depending on the type of variable. The expression
="3" + CalledNumber()
results, during the treatment of a call with CalledNumber()=234, in a string in the form
"3234".
The expression
= 3 + CalledNumber()
results, during the treatment of a call with CalledNumber()=234, in a numeric value
237
* 
If the variable or a system function (here CalledNumber()) contains a string, which is not interpretable as a numeric value, then this expression will generate an error (type mismatch) and the call will be terminated.
 
*Comparison
This operation runs analogous to Addition. Thus, the expression generates
"333" > CalledNumber()
a comparison of the strings.
If the variables to be compared are strings, they will be compared as ASCII strings (standard string comparison) starting with the first character. The first discrepency (> or <) determines the result.
Example:
The following strings exist: "A"=65; "a"=97; "b"=98; "c"=99.
Then the following apply:
"aab" < "aac", because 1st character a=a; 2nd character a=a; 3rd character b<c
"aab" > "aAc", because 1st character a=a; 2nd character a>A
The expression
333 > CalledNumber()
compares the numeric value. In this case it is once again necessary that the system function contains a numeric value.
The Use of Variables in E-Mail Texts
If you would like to use a variable in the text of a sent e-mail, you must define the entire text of the e-mail as an expression.
Example:
The following should appear later in the text of the e-mail:
You received at <CurTime> a call from the number <IpPbx.CallingNumber>.
An attempt to connect the call to <Substitute> was made.
Sincerely, your SwyxServer.
In this case, "Substitute" is a user-defined variable, which is defined during the execution of the script (e.g. depending on a number entered via DTMF by the caller or according to the time of the call, a different substitute is defined).
In this case, the following contents must be in the "Text" field in the block "Send E-mail":
= "You received a message at " & CurTime() & " from the number "_
& IpPbx.CallingNumber & "." & vbLF _
& "An attempt to connect the call to " & Substitute & " was made." & vbLF _
& "Sincerely, your SwyxServer."
* 
Make sure to use a blank between "vbLF" and the underscore.
 
Use the underscore (_) as the last symbol of the line in the editing of the expression for all lines except the last one and vbLF (Visual Basic Line Feed) as the symbol for the line break in the e-mail text.
System Functions
SwyxWare gives current information about the call just received for the processing by a script. This current information can be, for example
*assigned to a variable (3.6.6.1 Set Variable),
*inserted into the text of an e-mail ( The Use of Variables in E-Mail Texts or 3.6.5.10 Send email) or
* 
When using system functions, note that they only occur in expressions that are subject to the syntax listed above.
 
The following system functions are available:
Name
Explanation
IpPbx.Away
Add or define status "Away"
IpPbx.CallingName
Add or define the name of the caller
IpPbx.CallingNumber
Add or define the number of the caller
IpPbx.DoNotDisturb
Add or define "Do not disturb"
IpPbx.OneWayConference
Add mode for one-way conference
IpPbx.SecondaryCallingNumber
Add secondary number
IpPbx.UserFreeStatusText
Add or define statustext of the user
CallDuration()
Duration of the call in seconds
CalledNumber()
Add called number
CallID()
Number fort he unique identification of this call. This identification is also used in the Call Detail Records (CDRs).
CallStart()
Starting time of the call in the format hh:mm:ss
CurDate()
Current date in the format dd.mm.yyyy
CurDateTime()
Time and date of the beginning of the call in the format hh:mm:ss dd:mm:yyyy
CurDay()
Current day (with preceding zero) in the format dd
CurDayOfWeek()
Day of week of the begin of the call in the format e.g., "Monday"
CurHour()
Current hour (with preceding zero) in the format hh
CurMinute()
Current minutes (with preceding zero) in the format mm
CurMonth()
Current month (with preceding zero) in the format mm
CurSecond()
Current seconds (with preceding zero) in the format ss
CurTime()
Current time in the format hh:mm:ss
CurYear()
Current year (yyyy)
ExternalCall()
External call
InternalCall()
Interner Anruf
IsAway()
Status of the user is "Away"
IsBusy()
User is busy
IsDoNotDisturb()
Status of the user is "Do not disturb"
IsLoggedIn()
User is logged on to a device.
IsOutlookBusy()
Calendarstatus of the user is "busy"
IsOutOfOffice()
Calendarstatus of the user is "away"
LastCause()
Contains information about the last redirection action (connect to, loop, FollowMe) within the current call handling. The following values are possible:
*PBXSuccess (0)
*PBXFailure (1)
*PBXTimeout (2)
*PBXCallTermNormalCallClearing (3)
*PBXCallTermDestinationBusy (4)
*PBXCallTermReject (5)
*PBXCallTermWrongNumber (12)
*PBXCallTermConnectToCallerImpossible (13)
*PBXCallTermDestinationUnreachable (14)
*PBXNoChannelAvailable (18)
*PBXNetworkCongestion (19)
*PBXIncompatibleDestination (20)
*PBXOriginatorDisconnected (22)
NotLoggedIn()
Benutzer is logged off
OneWayConferenceSuffix()
Supplies the attachement, which was added to the destination number for one-way conference.
PIN()
Personal Identification Number of the person called.
PostDialingDigits()
Add suffix dial number
RecordLen()
Length of the recorded voice message in seconds
VoicemailOriginatorEMailAdress()
Insert e-mail address configured on the server of the sender of the voice message.