programming cusoon

Programming CUSoon is surprisingly simple. It is also surprisingly powerful. Programming is composed of two simple steps: creating of list of extracted data on your host computer and creating an email template (in both plain text and HTML formats) to receive that data: An example of plain text- and HTML-formatted templates appear in the next section, along with the introduction of a new CUSoon-specific tag <cu ...>. CUSoon also possesses the powerful capacity to manipulate the extracted data before it is inserted into the template, and this attribute is explained in the final section: Before you begin programming, you may wish to review CUSoon's philosophy. A brief summary of CUSoon's method of operation is presented in the technical fact sheet:

How CUSoon Works (31K PDF)



A. CREATING A LIST



CUSoon uses the concept of "watched folders" on your host computer(s). When a flat file containing a list similar to one below is placed in the watched folder (or a specified group, in the case of the HP3000's MPE), CUSoon will — on a regular basis — query the folder using FTP to see if one or more files exist in the folder. If the files exist, they are downloaded one at a time, processed and then sent out to their intended recipients. The process is repeated until all of the files in the watched folder have been downloaded and purged from the host.

As explained in the Installation Instructions, you may specify five different folders to be watched in CUSoon. Those folders may be on five different hosts, all on one, or in any combination. To create a list of information to be emailed to the various recipients, use your favorite query language to create a list similar to this:

                  TO: lmichols@miamibeach.fl.us
            DOCUMENT: bounced
             SUBJECT: Insufficient Funds Notice
               LAST = MICHOLS
              FIRST = LINDA
            COMPANY = City of Miami Beach
           ADDRESS1 = 1100 Washington Avenue
           ADDRESS2 = Fourth Floor
               CITY = Miami Beach
              STATE = FL
              CHECK = 33139
>>>
                  TO: brian.krasavge@eastman-kodak.com
            DOCUMENT: bounced
             SUBJECT: Insufficient Funds Notice
               LAST = KRASAVAGE
              FIRST = BRIAN
            COMPANY = Eastman Kodak Co
           ADDRESS1 = 1669 Lake Ave
           ADDRESS2 =
               CITY = Rochester
              STATE = NY
              CHECK = 14652
>>>
                  TO: fbraesek@miamibeach.fl.us
            DOCUMENT: bounced
             SUBJECT: Insufficient Funds Notice
               LAST = BRAESEKER
              FIRST = FRED
            COMPANY = City of Miami Beach
           ADDRESS1 = 1100 Washington Avenue
           ADDRESS2 = Fourth Floor
               CITY = Miami Beach
              STATE = FL
              CHECK = 33139
>>>
Although the text above has been aligned so that all of the colons and equal signs appear in the same column, that alignment is not required. Items that appear before the first colon or equal sign in a row are taken to be the variable names. Items that appear afterward are read as the values. All leading and trailing spaces are trimmed from the resulting text.

Information for each individual recipient must be separated by three greater symbols (">>>") on a line by itself.

Three pieces of information are mandatory in the list. A list isn't complete without each of these:
  • a TO: address for the email,
  • a DOCUMENT: name to be merged, and
  • a SUBJECT: line of the email.
The various document specification tags are:
TO:
DOCUMENT:
SUBJECT:
REPLYTO:
FORMAT: (where the two acceptable values are HTML and PLAIN).

If you specify the FORMAT of the emails to be transmitted in your retrieved list, that specification will override the formatting specifications that you have selected in CUSoon's configuration pulldown menu. Otherwise, including the FORMAT: specification is not necessary.

Document specifications are noted through the use of a colon (":") and they must come first in each record.

Variables are noted with the use of an equal sign ("="). One thousand variables may be specified to be included in each email letter, although it is our expectation that you will only use a few dozen at the extreme.

If HTML email is to be sent, a proper template (e.g., "welcomeletter.html") must be present in the /templates folder on the PC from which CUSoon is executing. Similarly, and virtually always required, a plaintext template (e.g., "welcomeletter.txt") must also be present there. However, if HTML email is never meant to be sent, the HTML-based document is not necessary.

The DOCUMENT: value can be specified in any of these manners:

DOCUMENT: welcomeletter
DOCUMENT: welcomeletter.txt
DOCUMENT: welcomeletter.html
All three of these notations are equivalent. The file extension at this point is irrelevant. When the document value is read, its extension is stripped off by CUSoon to get the name of the general document. The ".html" and ".txt" extensions are added back on to the document's name just before the appropriate document template, either plaintext or HTML, is to be retrieved.



B. CREATING TEMPLATES



For your use, an example of an "insufficient funds notice" template appears throughout this section.

A "plaintext" template in CUSoon is not plain text in the way that you might expect. Because CUSoon is intended to replace variables with their appropriate values, CUSoon requires the use of the <br> (linebreak) and <p> (new paragraph) HTML-like tags in order to provide a well-formatted document. CUSoon uses these tags to create the text structure in the manner that you specify it — after all variable substitution has occurred. CUSoon wraps the substituted text at line lengths of 72 characters or less so that it will appear appropriate and well-formatted to virtually all plain text email readers.

The HTML rules for the <br> and <p> tags, which CUSoon also obeys, are as follows:

  • a <br> tag specifies a simple linebreak (a CRLF).
  • a <p> tag specifies a new paragraph (a CRLF followed by a blank line and a second CRLF).
Immediately successive <p> tags are condensed by HTML (and CUSoon) into just one new paragraph request. However, immediately successive <br> tags are not condensed. Each one represents a new linebreak.

The <br> and <p> tags disappear from the plaintext output as they are consumed by CUSoon in reformatting the text and are not transmitted. The same is true of the <cu ...> tags, which are consumed when performing the variable substitutions.

All other HTML tags are left in the plaintext document. Whether using other HTML tags in a plain text document is a good idea or not depends greatly on the email reader used by the recipient. Most plain text readers will now support some portion of the HTML set of tags, most especially bolding, underlining, italicizing and hyperlinks, but not all do and their use is probably discouraged in plain text templates.

An example of a plain text CUSoon template:


<p>
INSUFFICIENT FUNDS NOTICE
<p>
Unfortunately, <cu name(first)>, we've had to return your check
No. <cu check> for $10,000.00 unpaid. Your account has been
charged a $21.30 handling fee.
<p>
Please call your customer service representatve at 505.555.5555
or click <a href="//first-universal-fcu.com/
nsf.asp?45134.<cu check>">
here for more information.
<p>
<b>First Universal FCU</b>
<p>


A matching HTML template for same "insufficient funds notice" emailing appears below. It is organized as an HTML table, containing three columns. The leftmost column is for a large image. The middle column is an empty, thin gutter column. The right column contains a header (written as an GIF image) and the appropriate text:


<p>
<center>
<table width=640 border=0 cellpadding=0>
<tr>
<td width=268>
<img src="//aics-research.com/art/scream.jpg">
</td>
<td width=19 align=left>
<td width=353 align=top>
<img src="//aics-research.com/art/bounced.gif">
<br>
<p>
<font size=3 face="Helvetica, Arial">
Unfortunately, we think that's true too, <b><cu name(first)>.</b>
<p>
We've had to return your check No. <cu check< for $10,000.00 unpaid
and your account has been charged a $21.30 handling fee.
<p>
Please call your customer service representatve at 505.555.5555
or click
<a href="//first-universal-fcu.com/nsf.asp?45134.<cu check>"> here>/a> for more information.
<p align=right>
<b>First Universal FCU</b>
</font>
</table>
</center>

The resulting "insufficient funds notice" HTML emailing appears below, with data filled in:



Unfortunately, we think that's true too, Wayne.

We've had to return your check No. 12345 for $10,000.00 unpaid and your account has been charged a $21.30 handling fee.

Please call your customer service representatve at 505.555.5555 or click here for more information.

First Universal FCU




C. VARIABLE SUBSTITUTION



Variable substitution is accomplished using the CUSoon-specific tag <cu ...>. Variable substitution in CUSoon can be as simple as <cu check>, where the check value that was specified in your query-extracted list is substituted into the text.

However, significant text and numeric processing capabilities are also a part of CUSoon and a tag such as <cu name(first & " " & last)> is just as easily accomplished (where the first and last names of the recipient are concatenated with an intervening space and appropriately capitalized).

Further, new variables, such as "first", can be created within the body of the emails using the DEF construct, as outlined below. Once defined, they can be used elsewhere in the text.

In this instance, presume that WHOLENAME is extracted from the host's database in this form: ROGERS/WAYNE, and the first name needs to be properly parsed and capitalized. All of this is accomplished in the first DEF statement:
<cu def first:name(sub(wholename,pos(wholename,"/")+1))>
INSUFFICIENT FUNDS NOTICE
<p>
Unfortunately, <cu first>, we've had to return your check
No. <cu check> for <cu amount> unpaid. Your account has been
charged a $21.30 handling fee.
<p>
Please call your customer service representatve at 505.555.5555
or click
<a href= "//first-universal-fcu.com/nsf.asp?45134.<cu check>">
here</a> for more information.
<p>
<b>First Universal FCU</b>

Because the <cu def ...> construct is only defining a new variable, it has no impact on the formatting of the document that will be eventually outputted and can be placed anywhere in the text. However, it must occur prior to the first use of the defined variable, as it must in any similar computer language.



D. CUSOON FUNCTIONS


arithematic operators
^       exponention
* /      multiplication, division
+ -     addition, subtraction
text operators
&       text concatenation
numeric functions
ABS(numeric)
INT(numeric)
RND(numeric)
SGN(numeric)
SQR(numeric)
EXP(numeric)
LOG(numeric)
LN(numeric)
POS(source-string,sought-string)
text functions
ENGLISH(numeric)
UPS(text)  
DNS(text)  
CAP(text)  
DEB(text)  
NAME(text)  
SUB(text,start,stop)
RIGHT(text,length)
date and time functions
DATE#(date,optional offset)*
date1 ® 050820
date2 ® 20050820
date3 ® August 20, 2005
date4 ® AUG 20 2005
date5 ® 05-AUG-2005
date6 ® 08/05/2005 (American)
date7 ® 05.08.2005
date8 ® 08/05/2005 (European)

DAY#(date,optional offset)*

day1 ® Wednesday
day2 ® WED

MONTH#(date,optional offset)*

month1 ® February
month2 ® FEB

YEAR(date,optional offset)*

TIME(entry = 12 or 24)

* If the offset is specified as a simple number, the units are in days. Alternate specifications are also in months (e.g., "-4m") and years (e.g., "5y").


CUSoon home page