Evaluate Expression module
This module
is used to direct the caller to a different part of the script
based on the Result Variable, Boolean expression or an Arithmetic
expression specified. This module is used when the call is to go to
different parts of script depending on:
-
Caller
ID,
-
Time and Date
of the call,
-
Information
entered by caller,
-
Information was
retrieved using the DB Query modules or Run program modules.
-
Any VBScript
expression (see here for complete
list of functions)
The result of
the evaluated expression will be assigned to the $RV[module
title] Result
Variable.
Optionally
the result can also be assigned to a user specified Result
Variable. This is useful when implementing counters or other more
advanced call flow management.
The name of
the user specified Result Variable can be anything. The user
specified variable can be accessed in other parts of the script
using $RV[user specified variable]
format.
Selecting "Make Global RV" will
make the created variable a "Global Result Variable". Global RVs
need only be used if many different lines want to be able to
read/set a central globally available variable which is retained by
VoiceGuide as long as the software is running and does not get
reset when any new calls arrive on any lines. (This option is used
only in rare circumstances).
Selecting the
"Store results in log file" option will ensure the results will be
stored along with other call details. If the option is not selected
the Result Variables will still be accessible within other parts of
the script, but they will not be saved in the call log.
Paths
Chosen:
If a
Result Variable
or an Arithmetic
expression is specified:
-
if any of
the paths
match the result
exactly then that path will be taken.
-
If none of the
Paths match the value exactly, but the result is non-empty then the
"True" path will be taken.
-
If the result
is empty, then the False path will be taken.
If a Boolean
expression is specified:
-
A True or a
False path will be taken depending on what was the result of the
expression.
Example
1:
The Evaluate
Expression can be used to switch to different parts of the script
based on Caller ID. To switch based on the caller's phone number
use $RV_CIDNUMBER as the Result Variable to be
evaluated :
And when
specifying the paths, use the telephone number in the { }
section.
eg: If
$RV_CIDNUMBER was used, and you want to
handle calls from number 5625551234 in a special way, the path to
send all the calls from this number to a particular module would
be:
On
{5625551234} Goto [Say Hi to Mum]
you could also use:
on {} goto
[NoCallerId]
or
on {False} goto
[NoCallerId]
both of which will match if CallerID number is blank.
on {True} goto
[CallerIdWasSent]
will be taken if CallerID was provided but no specified path
explicitly matched the number:
Example
2:
The Evaluate
Expression module is used to check the PIN entered in previous Get
Number module titled "Get PIN".
And the paths
in this case are defined as:
What do the
paths do:
|
On {False} Goto [Get
PIN]
|
If for some reason no PIN
was entered, and $RV[Get PIN] holds no numbers, then goto the Get
PIN module
|
|
On {1234} Goto [Voicemail
Box 2032] Return [Main Menu]
|
If the entered PIN was 1234
then go to the Voicemail box number 2032, and then when the caller
has finished leaving the message return the caller to the Main Menu
module
|
|
On {5678} Goto [Voicemail
Box 8423] Return [Main Menu]
|
If the entered PIN was 5678
then go to the Voicemail box number 8423, and then when the caller
has finished leaving the message return the caller to the Main Menu
module
|
|
On {True} Goto [Invalid
PIN]
|
A PIN was entered and
$RV[Get PIN] does hold some entered number, but that number does
not match exactly any of the paths specified. Go to the Invalid PIN
module.
|
It is a good
idea to always specify the TRUE and FALSE paths, since VoiceGuide
will hang up the call if it cannot find a valid path to go to the
next module.
Example
3:
The Evaluate
Expression module can also be used to perform calculations.
Eg: To
calculate whether the number of widgets ordered is more then the
available amount you can use the following expression:
($RV[LokupStockAvail_1_1]
- $RV[GetOrderAmount]) >= 0
A True or a
False path will be taken depending on what was the result of the
expression.
Example
4:
The Evaluate
Expression module can also be used to compare strings. An example
of valid expression to evaluate is:
"$RV[DB_Retrieve_1_1]"="Available"
A True or a
False path will be taken depending on what was the result of the
above expression
Example
5:
If you need
to evaluate a Result Variable that holds a string, and select
different paths depending on the string’s value then the string
will need to be specified using quotes or “CStr()” function:
"$RV[DB_Retrieve_1_1]"
or:
Cstr($RV[DB_Retrieve_1_1])
you will need
to use and use the different possible values of this variable when
specifying the On ( ‘Paths’ where the script
Example
6:
The “+” or
the “&” operator can also be used to concatenate strings
together.
eg: The
following is a valid expression to use:
["1_" + Cstr($RV_DAY) & "_2"]
The result is
going to be (on a Saturday):
1_6_2
Example
7:
If comparing
dates the # character should be used around the date
expressions.
eg: The
following expression determines if current date is between 7th July
2007 and 31 December 2008:
(#7/7/2007# <=
#$RV_MONTH/$RV_DATE/$RV_YEAR#) and (#$RV_MONTH/$RV_DATE/$RV_YEAR#
<= #31/12/2008#)
Example 8:
To add the value of the number
entered in module "GetValue1" to the value of the number entered in
module "GetValue2" the following expression would be used:
$RV[GetValue1] +
$RV[GetValue2]
The result will be assigned to the
result variable name for the module, or can be assigned to a Result
Variable specified in the "Assign result to following Result
Variable" field.
Example 9:
Evaluate expression can be used as
a sophisticated Time-Switch as well. eg. To check if the current
day is either New Year's Day or Christmas Day the following
expression can be used:
(("$RV_DD" = "01") and
("$RV_MM" = "01")) or (("$RV_DD" = "25") and ("$RV_MM" =
"12"))
Example
10:
Evaluate
Expression module can be used to implement a counter to check
the number of times the caller goes though certain parts of the
call flow. This example demonstrates how a counter can be
implemented.
A user
defined Result Variable is created and its value is set to zero.
Note that as the Result Variable was assigned a value of 0, the
'False' path will be taken from this module.
The counter
in incremented by retrieving the current value of the user defined
Result Variable, adding 1 to this current value, and then saving
the result back into the user defined Result Variable.
The value
saved by this Evaluate Expression module is then used in the Paths
section to determine the next module the script should branch
to.
List of functions which can be
used:
Any VBScript type expression can
be evaluated using the Evaluate Expression module. The full list of
functions/operators/constants/keywords etc which can be used can be
found at:
http://msdn.microsoft.com/library/en-us/script56/html/vbscripttoc.asp
Functions which can be used
in the Evaluate Expression module:
| Abs
|
Returns
the absolute value of a number
|
| Array
|
Returns
an array.
|
|
Asc
|
Returns
the ASNI character code corresponding to the first letter in a
string.
|
|
Atn
|
Returns
the arctangent of a number.
|
|
CBool
|
Returns
an expression that has been converted to a Boolean
variant.
|
|
CByte
|
Returns
an expression that has been converted to a Byte
variant.
|
|
CCur
|
Returns
an expression that has been converted to Currency
variant.
|
|
CDate
|
Returns
an expression that has been converted to a Date
variant.
|
|
CDbl
|
Returns
an expression that has been converted to a Double
variant.
|
|
Chr
|
Returns
the character associated with the specified ANSI character
code.
|
|
CInt
|
Returns
an expression that has been converted to an Integer
variant.
|
|
CLng
|
Returns
an expression that has been converted to a Long
variant.
|
|
Cos
|
Returns
the cosine of an angle.
|
|
CreateObject
|
Creates
and returns a reference to an Automation object.
|
|
CSng
|
Returns
an object that has been converted to a Single
variant.
|
|
CStr
|
Returns
an expression that has been converted to a String
variant.
|
|
Date
|
Returns
the current system date.
|
|
DateAdd
|
Returns
a date to which a specified time interval has been added.
|
|
DateDiff
|
Returns
the number of intervals between two dates.
|
|
DatePart
|
Returns
the specified part of a given date.
|
|
DateSerial
|
Returns
a Date variant for a specified year, month and day.
|
|
DateValue
|
Returns
a Date variant.
|
|
Day
|
Returns
the day of the month (1-31).
|
|
Exp
|
Returns e
raised to a power. |
|
Filter
|
Returns
a subset of a string array based on a specified filter
criteria.
|
|
Fix
|
Returns
the integer portion of a number.
|
|
FormatCurrency
|
Returns
an expression formatted as a currency value.
|
|
FormatDateTime
|
Returns
an expression formatted as a date or time.
|
|
FormatNumber
|
Returns
an expression formatted as a number.
|
|
FormatPercent
|
Returns
an expression formatted as a percentage.
|
|
GetObject
|
Returns
a reference to an Automation object from a file. Windows NT
systems only. |
|
Hex
|
Returns
a string representing the hexadecimal value of a number.
|
|
Hour
|
Returns
the hour of the day (0-23).
|
|
InputBox
|
Displays
a prompt in a dialog box. Client-side
only. |
|
InStr
|
Returns
the position of the first occurrence of one string within
another.
|
|
InStrRev
|
Returns
the position of an occurrence of one string within another, working
from the end of the string.
|
|
Int
|
Returns
the integer portion of a number.
|
|
IsArray
|
Returns
a Boolean value indicating whether a variable is an array.
|
|
IsDate
|
Returns
a Boolean value indicating whether an expression can be converted
to a date..
|
|
IsEmpty
|
Returns
a Boolean value indicating whether a variable has been
initialized.
|
|
IsNull
|
Returns
a Boolean value indicating whether an expression contains no valid
data (Null).
|
|
IsNumeric
|
Returns
a Boolean value indicating whether an expression can be evaluated
as a number.
|
|
IsObject
|
Returns
a Boolean value indicating whether an expression references a valid
object.
|
|
Join
|
Returns
a string created by joining a number of substrings contained in an
array.
|
|
LBound
|
Returns
the smallest available subscript for the indicated dimension of an
array.
|
|
LCase
|
Returns
a string that has been converted to lower case.
|
|
Left
|
Returns
a specified number of characters from the left side of a
string.
|
|
Len
|
Returns
the number of characters in a string or the number of bytes
required to store a variable.
|
|
LoadPicture
|
Returns
a picture object.
|
|
Log
|
Returns
the natural logarithm of a number.
|
|
LTrim
|
Returns
a copy of a string without leading spaces.
|
|
Mid
|
Returns
a specified number of characters from a string.
|
|
Minute
|
Returns
the minute of the hour (0-59)
|
|
Month
|
Returns
the number of the month (1-12)
|
|
MonthName
|
Returns
a string with the name of the specified month.
|
|
MsgBox
|
Displays
a message in a dialog box. Client-side
only. |
|
Now
|
Returns
the current date and time set on your computer system.
|
|
Oct
|
Returns
a string representing the octal value of a number.
|
|
Replace
|
Returns
a string in which a specified substring has been replaced with
another substring a specified number of times.
|
|
RGB
|
Returns
a whole number representing an RGB color value.
|
|
Right
|
Returns
a specified number of characters from the right side of a
string.
|
|
Rnd
|
Returns
a random number.
|
|
Round
|
Returns
a number rounded to a specified number of decimal places.
|
|
RTrim
|
Returns
a copy of a string without trailing spaces.
|
|
ScriptEngine
|
Returns
a string containing the scripting language in use.
|
|
ScriptEngineBuildVersion
|
Returns
the build version number of the script engine in use.
|
|
ScriptEngineMajorVersion
|
Returns
the major version number of the script engine in use.
|
|
ScriptEngineMinorVersion
|
Returns
the minor version number of the script engine in use.
|
|
Second
|
Returns
the second (0-59).
|
|
Sgn
|
Returns
an integer indicating the sign of a number.
|
|
Sin
|
Returns
the sine of an angle.
|
|
Space
|
Returns
a string consisting of the specified number of spaces.
|
|
Split
|
Returns
an array containing a specified number of substrings.
|
|
Sqr
|
Returns
the square root of a number.
|
|
StrComp
|
Returns
a value indicating the result of a string comparison.
|
|
StrReverse
|
Returns
a string in which the character order of a specified string is
reversed.
|
|
String
|
Returns
a repeating character string of the length specified.
|
|
Tan
|
Returns
the tangent of an angle.
|
|
FormatDateTime
|
Returns
a Date variant with the current system time.
|
|
TimeSerial
|
Returns
a Date variant with the time for a specific hour, minute,
and second.
|
|
TimeValue
|
Returns
a Date variant containing the time.
|
|
Trim
|
Returns
a copy of a string without leading or trailing spaces.
|
|
TypeName
|
Returns
a string that provides Variant subtype information about a
variable.
|
|
UBound
|
Returns
the largest available subscript for the indicated dimension of an
array.
|
|
UCase
|
Returns
a string that has been converted to upper case.
|
|
VarType
|
Returns
a value indicating the subtype of a variable.
|
|
Weekday
|
Returns
a whole number representing the day of the week.
|
|
WeekdayName
|
Returns
a string containing the specific day of the week.
|
|
Year
|
Returns
a whole number containing the year.
|
Operators which can be used
in Evaluate Expression module:
| Operator
|
Description
|
|
Addition (+)
|
Sum two
numbers.
|
|
And
|
Perform
a logical conjunction on two expressions.
|
|
Assignment (=)
|
Assign a
value to a variable or property.
|
|
Concatenation (&)
|
Force
string concatenation of two expressions.
|
|
Division (/)
|
Divide
two numbers and return a floating point result.
|
|
Eqv
|
Perform
a logical equivalence on two expressions.
|
|
Exponentiation (^)
|
Raise a
number to the power of an exponent.
|
|
Imp
|
Perform
a logical implication on two expressions.
|
|
Integer Division (\)
|
Divide
two numbers and return an integer result.
|
|
Is
|
Compare
to object reference values.
|
|
Mod
|
Divide
two numbers and return the remainder.
|
|
Muliplication (*)
|
Multiply
two numbers.
|
|
Negation (-)
|
Indicate
the negative value of a numeric expression.
|
|
Not
|
Perform
logical negation of an expression.
|
|
Or
|
Perform
logical disjunction on two expressions.
|
|
Xor
|
Perform
a logical exclusion on two expressions.
|
|
Subtraction (-)
|
Find the
difference between two numbers.
|