Belle Nuit Montage - Editing etc. - Lausanne - Suisse - e-mail: matti@belle-nuit.com
Homepage : Textfilter : Examples [ Index - EDL - HTML - Registration - Subtitle] - Search - Sitemap
The following is an example how to use Textfilter in a real-world context. If you did not read the Userguide yet, you may want to do that before, so that you can follow each step below.
You can build the project following the explications, but you can also open the project (which is a textfile) from this link Registration Project. If you are reading this from internet, click on the link, save it as a textfile and then open it with Textfilter.
I sell my subtitler program through Kagi.com. When a customer buys a license of the program, Kagi sends me an email with the following content:
Payment fee received:
1 Quantity Payment for Belle_Nuit_Subtitler, US 89
Registered-To: Martin Scorsese
Email: martin@tribeca.com
Postal: NYC (NY) USA
Total Amount Paid: USD 89
Date: 2001-12-18
Processed: 2001-12-18
...
I then send the customer an email with the registration code which is based on the username.
Before Textfilter, I had to write down the Username, type it into my register application, and then write the code into email. Well, I could use copy and paste, but it was still a lot of operations. With a Textfilter floating filter, i can just drag the mail to the floating window and it creates me the answer mail text for the customer on the fly.
Open a new textfilter project. Remove the Input file filter and add a Clipboard filter. You may put the above email text into the clipboard to see what happens.
I first need to extract the username and the email address. The mail from Kagi creates lines with a keyword and a value, separated by the colon ":". To parse this, i add first a Custom parse filter and set the separator to ":". Set the Headings parameter to "key,value", and you get a table like
|
Payment fee received |
|
|
1 Quantity Payment for Belle_Nuit_Subtitler, US 89 |
|
|
Registered-To |
Martin Scorsese |
|
|
martin@tribeca.com |
Add a Script filter with the following text
dim text as string
text = gettext
select case getcolumnname
case "key"
setkey "key", text
case "value"
setkey getkey("key"), text
end select
The text output will be empty, but we will have set key values, eg. the key "Registered-to" will have the value "Martin Scorsese" and the key "Email" will have the value "martin@tribeca.com". Use the Get Info command of the Window menu. You can see that the keys have been set.
Note: Actually, the filter will not work as expected, if you copy-paste the above code to the script filter. This is because you have changed the clipboard! Noew you can use two strategies to workaround this: Write the whole filter and then refill the clipboard. Or use temporarily a Insert Text filter to simulate some input and at the end replace it with the Clipboard filter, when everything works fine.
Add a Text Parser filter to go back to text mode.
Add an Insert Text filter. Here, we will set our text template, which will be used by the script below. Add a text like
<email>
Dear <registered-to>,
thank you for your confidence in belle nuit subtitler. for the registration, you need to enter the following username and serial number. please take care to type exactly (including capitals) to match the serial number to the username.
username: <registered-to>
serial number: <registrationkey>
with kind regards
matthias bürcher
Finally, add a Script filter with the following script:
function getregistrationkey(s as string) as string
dim i,mykey,v as integer
dim test,result as string
mykey = 13
test = left(s+" ",8)
for i = 0 to 3
v = asc(mid(test,2*i+1,1))
result = result + right(hex(v+mykey),2)
v = asc(mid(test,2*i+2,1))
result = result + right(hex(v+mykey),2)
if i<3 then
result = result + "-"
end if
next
return result
end functiondim text as string
text = gettext
text = replaceall(text,"<registered-to>",getkey("registered-to"))
text = replace(text,"<email>",getkey("email"))
text = replace(text,"<registrationkey>",getregistrationkey(getkey("registered-to")))
print text
The script replaces all special tags of the template with the key values we extracted above. It also has an internal function to calculated the registration key (which, of course, is fake).
Save the project.
Select the project window and select the window menu Floating Filter (command-2). Now, the filter is a global floating window. You can go into Emailer, open your Email from Kagi, drag the text to the Floating Filter, and drag back the resulting text to a new email. Voilà, c'est tout.
Textfilter was written with REALbasic, http://www.realsoftware.com
![]()
Homepage : Textfilter : Examples [ Index - EDL - HTML - Registration - Subtitle] - Search - Sitemap
e-mail: matti@belle-nuit.com - www.belle-nuit.com - 5.5.02