|
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
- examples:
DeleteCall;
Export(<data to export>, <file format>, '<filename>');
- <data to export> is one of elCalls, elContacts, elActions
- <file format> is efCSV, efHTML, or efTEXT
- exports a database to a file
- 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
- examples:
Log('calls.txt', CallInfo.DateTimeStr + ' - Call from ' + CallInfo.Name + ' at ' + CallInfo.Number);
Log('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!');
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 + '" ');
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 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');
Speak('<text>');
- speaks specified text if speech support is installed
- examples:
Speak('Someone called');
Speak('Call from ' + CallInfo.Name + ' at ' + CallInfo.Number);
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:
Ascendis Caller ID adds the following functions to the standard DWS functions:
function BoolToStr(<boolean>): String;
- returns "True" or "False" depending on <boolean>
function CallCount: Integer;
- returns the number of calls in the Calls list
function GetRawNumber(<phone number string>): String;
- removes all non-digit characters from <phone number string>
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 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 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 the {$INCLUDE '<pathname>'} directive. This 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. For example:
{$INCLUDE 'C:\Dev\DWS\Functions.inc');
{$INCLUDE 'D:\DateLib.pas');
DWS does not support 'uses'. The $INCLUDE directive should be used instead. There is currently no way to "include" an action.
You may find more information on specific script commands by browsing or searching the Ascendis Caller ID forums on our web site.
|