Script Language (DWS)

Top  Previous  Next  Contents  Index 

Since version 1.6.5.0, Ascendis Caller ID has supported a second script language, known as DWS.  DWS stands for Delphi Web Script, and is an open source scripting language based loosely on Delphi.  Its home is here:

http://sourceforge.net/projects/dws/

 

 

Specifically, Ascendis Caller ID supports DWS II 2.0.

 

DWS is a programming language similar to Delphi, which is itself an extended version of Pascal.  Here are some highlights:

Identifiers are case-insensitive.
Statements must be separated by semicolons.
While you can put multiple statements on a single line, it is usually considered bad form to do so.
Lines starting with '//' are comments and are ignored.
Text contained between '{' and '}' are comments and are ignored.
'Program' declarations are not neither required nor supported within an action script.
Procedures and functions are supported, but they are not required.
Macros are not supported as in Easy Actions and the original script processor.  Use the CallInfo object instead.
String literals must be enclosed in single quotes (i.e., 'this is a string literal' but "this is not valid")

 

An enhanced Backus-Naur definition of DWS provides a more complete definition.

 

All DWS scripts must contain the following line before any commands:

// LANGUAGE=DWS

This tells Ascendis Caller ID not to use the original script processor.

 

 

DWS in Ascendis Caller ID supports the following commands:

 

DeleteCall;

deletes current call when the call ends
if desired, use this command for calls that you don't want to keep in the Call list
examples:

DeleteCall;

 

 

Export(<data to export>, <file format>, '<filename>');

exports a database to a file
<data to export> is one of elCalls, elContacts, elActions
<file format> is efCSV, efHTML, or efTEXT
if <filename> does not contain a path specification, the Ascendis Caller ID folder will be used
examples:

Export(elCalls, efHTML, 'calls.htm');

Export(elContacts, efCSV, 'contacts.csv');

Export(elActions, efText, 'actions.txt');

 

 

HangUp;

hangs up the phone
examples:

HangUp;

 

 

Log('<filename>', '<log text>');

adds a line to named text file consisting of '<log text>'
if <filename> does not contain a path specification, the Ascendis Caller ID folder will be used (Windows Vista and Windows 7 will probably not allow this, since the program folders are protected.)
examples:

Log('C:\calls.txt', CallInfo.DateTimeStr + ' - Call from ' + CallInfo.Name + ' at ' + CallInfo.Number);

Log('D:\Documents\privateCalls.txt', CallInfo.DateTimeStr + ' :: Another anonymous call!');

 

 

LogActivity('<log text>');

adds a line to the Activity Log
examples:

LogActivity('Hanging up on {Name} at {Number}');

LogActivity(CallInfo.DateTimeStr + ' :: Another anonymous call!');

 

 

PerformAction('<actionName>');

performs the action named <actionName>
use this if another action already contains part or most what you want to accomplish
If another action already does exactly what you need, it's usually better to change the contact to use that action directly.  However, if that would entail changing many contacts, or if the actions might be different in the future, calling the other action using this command may be prudent.
by splitting actions into common tasks, you can reuse actions without duplicating them
examples:

PerformAction('Block');

PerformAction('Look for caller in Google');

PerformAction('Send email to cell phone');

 

 

PhoneSound('<filename>');

plays the wave file specified by <filename> over the phone (use the Sound command to play sounds over the computer's speakers)
if <filename> does not contain a path specification, the Ascendis Caller ID folder will be used
examples:

PhoneSound('Disconnect Tones.wav');

Notes:

The PhoneSound command will only work with correctly configured voice modems. Ascendis Caller ID's Repair Modem command does not correct voice mode configuration issues.
Voice modems typically only support certain kinds of wave files. Usually they support wave files in PCM format sampled at 8 kHz, 16 bit, mono. You can use Windows' Sound Recorder or the free Audacity sound editor program to convert other wave files to this format. If you pass an incorrectly formatted wave file to PhoneSound, you'll get something like this in the Activity Log:

waveOutOpen() -- The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats.

Ascendis Caller ID only supports the PhoneSound command in TAPI mode
Windows Vista and Windows 7 have a known bug where they cannot play sounds over the phone with modems based on Conexant chipsets.  This includes most Zoom modems, including the recommended Zoom 3049C external serial modem and Zoom 3095 external USB modem.  Zoom has been notified and is communicating with Microsoft and/or Conexant, however, no resolution has been announced.
Technical details:
This bug appears when using TAPI to play sounds over modems, which is how most programs play sounds over modems, and is the only method supported in Ascendis Caller ID.
It is not known how many Conexant chipsets are affected; it is possible one or more Conexant chipsets work as expected.
The bug is in Windows, not Conexant's chipsets.  Windows is incorrectly converting sound files to the desired format for the Conexant chipsets.  Other modems that work use other sound formats.  The modems work properly when used with Windows XP.

 

 

Run('<filename>'[, '<arguments>']);

starts program specified by <filename> with optional arguments or opens specified document
examples:

Run('notepad');

Run('myprogram.exe', CallInfo.RawNumber);

Run('showargs.exe',

'"' + CallInfo.FirstName + '" ' +

'"' + CallInfo.LastName + '" ' +

'"' + CallInfo.RawNumber + '" ' +

'"' + CallInfo.DateTimeStr + '" ');

 

 

RunWait('<filename>'[, '<arguments>'][, <window state>]);

Starts a program and waits for it to finish. The user interface of Ascendis Caller ID will be frozen until the program ends, so only use for programs that don't take long to complete.  In general, Run() should be used instead.
<filename> = program to run or document to open (use full path to program/document unless it exists on system path or in Ascendis Caller ID Program Files folder)
<arguments> = optional command-line arguments to pass to program
<window state> = optional constant indicating state of window for launched program; if not specified SW_SHOWNORMAL is used:

Constant

Description

SW_HIDE

Hides the new program window and activates another

SW_MAXIMIZE

Maximizes the new program window

SW_MINIMIZE

Minimizes the new program window

SW_RESTORE

Activates the new program window and restores it to its previous state

SW_SHOW

Activates the new program window and shows it in its normal state

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Returns program exit code (integer)
examples:

RunWait('MakeDataFile.exe', 'C:\Temp.dat ' + CallInfo.RawNumber);

if RunWait('GetSecretCode.exe', '"' + CallInfo.Number + '"', SW_SHOWMINNOACTIVE) > 0 then

begin

LogActivity('FATAL ERROR: could not get secret code');

Exit;

end;

 

 

SendMail('<from>', '<recipients>', '<subject>', '<message>' [, '<cc list>' [, '<bcc list>']]);

sends email from <from> to <recipients> with specified <subject> and <message>
separate multiple recipients with commas
optional <cc list> indicates recipients of carbon copies
optional <cc list> indicates recipients of blind carbon copies (i.e., recipients don't see other recipients)
sendmail uses the Mail options specified in the Options window
examples:

SendMail('AscendisCallerID@home.com', 'me@work.com', 'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number, '');

SendMail('computer1@home.net', 

'myPager@pagerEmail.com, jimsPager@pagerEmail.com',

'Important Call',

'Call from ' + CallInfo.Name + ' at ' + CallInfo.Number,

'myMobile@cellphone.com');

 

 

SendMailFromFile('<filename>');

sends email with parameters specified in file <filename>
if <filename> does not contain a path specification, the Ascendis Caller ID program folder will be used
The contents of <filename> should be in the following format:

From: <from address>

To: <to address(es)>

Subject: <subject>

<mandatory blank line>

<message lines>


Example mail file:


From: "Automated System" <nowhere@somewhere.com>

To: Chief@mydomain.com

Subject: Sales Data


Today's sales:

--------------

Basic Widgets:   62 units

Advanced Widgets: 24 units

Universal Widgets: 19 units

 

 

SendMailFromFile uses the Mail options specified in the Options window
use this command when the mail contents are generated by another program, or the message is longer than one line
examples:

SendMailFromFile('SalesData.txt');

 

 

ShowMessage('<message>' [, WARNING|ERROR|INFORMATION]);

shows a modeless window containing <message> and an OK button
WARNING, ERROR, or INFORMATION determines which icon to use in the window.  If this parameter is not specified, INFORMATION is used.
the window will automatically timeout and disappear after 60 seconds
<message> is logged to the Activity log
examples:

ShowMessage('Entering untested code');

ShowMessage('{Name} should not be calling here anymore', WARNING);

 

 

Sound('<filename>');

plays the wave file specified by <filename>
if <filename> does not contain a path specification, the Ascendis Caller ID folder will be used
examples:

Sound('C:\Windows\Media\chimes.wav');

Sound('Unknown.wav');

Note: to play sounds over the phone, use the PhoneSound command

 

 

Speak('<text>');

speaks specified text if speech support is installed
examples:

Speak('Someone called');

Speak('Call from ' + CallInfo.Name + ' at ' + CallInfo.Number);

 

SpeakWait('<text>');

speaks specified text if speech support is installed and waits for it to finish
example:

RunWait('PauseMusic.exe');

SpeakWait('Call from ' + CallInfo.Name + ' at ' + CallInfo.Number);

RunWait('ResumeMusic.exe');

 

 

Volume(<volume>);

<volume> is between 0 (silence) and 65535 (loudest)
changes system volume to <volume> for all following Sound and Speak commands in script
overrides volume settings in Options window, except "Disable sound (including speech) in all actions"
examples:

Volume(65535);

Speak('Call from ' + CallInfo.Name);


Hangup;

Volume(1000);

Speak('Hanging up on telemarketer');

 

 

Some commands are also available as Easy Actions.

 

Information about the current call can be accessed through the CallInfo object.

 

 

Ascendis Caller ID includes the following standard DWS libraries:

DWS String Library
DWS File Library
DWS Date & Time Library
DWS Classes Library
DWS Ini Library

 

For a more comprehensive list of functions included with DWS, please see the DWS documentation.  You can download it from the DWS web site.  Some functions or libraries may not be available from Ascendis Caller ID scripts; please test desired functions before assuming they will work.

 

Ascendis Caller ID adds the following functions to the standard DWS functions:

function CallCount: Integer;

returns the number of calls in the Calls list

 

function ContactCount: Integer;

returns the number of contacts in the Contacts list

 

function GetCanonicalNumber(<phone number string>): Integer;

converts passed <phone number string> into Microsoft canonical format
example: GetCanonicalNumber('8005551212') returns +1 (800) 555-1212
If you get the error "The TAPI configuration information is unusable" you need to open the "Phone and Modem Options" control panel and set your local area code.

 

function GetComputerName: String;

returns the NetBIOS name of the computer the script is running on

 

function GetDataFolder: String;

returns the absolute path to the folder where Ascendis Caller ID stores the data files, including the database

 

function GetRawNumber(<phone number string>): String;

removes all non-digit characters from <phone number string>

 

function GetSettingBool(name: String): Boolean;

returns the value of the Boolean setting with the specified name
if the named setting doesn't exist, an exception is raised
if the named setting is not a Boolean setting, an exception is raised
the settings are not documented, but the Technical Support Report contains a list at the end
setting names rarely change, but we reserve the right to do so without notice

 

function GetSettingStr(name: String): String;

returns the value of the setting with the specified name
if the named setting doesn't exist, an exception is raised
the settings are not documented, but the Technical Support Report contains a list at the end
setting names rarely change, but we reserve the right to do so without notice

 

function GetTickCount: Integer;

returns number of ticks (1/1000 of a second) since Windows started

 

function NewCallCount: Integer;

returns the number of new calls in the Calls list

 

function PhoneCount: Integer;

returns the number of unique phone numbers in the database

 

function PhoneNumbersMatch(<phone number string 1>, <phone number string 2>): Boolean;

determine whether two phone numbers match, with or without leading '1'
converts each number to raw format before comparing

 

 

If you want to keep often used functions and procedures in a shared location, use one of the following $INCLUDE directives:

{$INCLUDE '<pathname>'}

loads the contents of <pathname> into the current script as if they were defined in the script itself
<pathname> must include an absolute path to the file

{$INCLUDE 'C:\Dev\DWS\Functions.inc'}

{$INCLUDE 'D:\DateLib.pas'}

 

{$INCLUDE_ACTION '<action name>'}

loads the contents of action <action name> into the current script as if they were defined in the script itself
action <action name> must exist

{$INCLUDE_ACTION 'Outlook Lib'}

{$INCLUDE_ACTION 'My Library'}

 

 

You may find more information on specific script commands by browsing or searching the Ascendis Caller ID forums on our web site.