[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - basic macro & scripting help [Mod: Moved]

basic macro & scripting help [Mod: Moved]

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

basic macro & scripting help [Mod: Moved]

Postby janrif » Fri Nov 19, 2004 7:12 am

Having trouble getting the gist of how these two elements work in Poco. Not Poco's fault; I'm no techie but I shouldn't have to be.

I've read some of the help/script files but would it appreciate it if someone would show me a simple thing. From that I might be able to grasp an overview.

I would like to sign my poco mail list (not on this forum) with a signature tempate that includes Poco information, i.e. version, etc.

When I tried it, I got the maros, not the output.

Would very much appreciate this small sample just to get me started. TIA

Edit: Moved to Pocoscript by Eric
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Postby Sandy » Fri Nov 19, 2004 8:09 am

What was missing in Help for scripting?
Sandy
 

Postby Michael » Fri Nov 19, 2004 2:05 pm

I am not aware of a common variable tag that provides information such as the Poco version number. As such the only way to do this would be to use a script. There are two Poco variables that can be used in this context, they are the #PocoVersion (build number) and the $PocoVersion (same information as in the X-Mailer header). You would have to create a script that would scan the outgoing message for a custom tag and replace it with the appropriate value.

I have to run off to the ferry to pick up my wife so I don't have time at the moment to provide sample code for this. I will try to remember to do so in the next couple of days (if someone else hasn't). If I forget to please post a reminder to this thread or send me a private message.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Michael » Sat Nov 20, 2004 2:48 am

One other note regarding this functionality. I have suggested a modification to the PocoScript engine that would address this. This modification covers much more than just this area but would, in my opinion, provide a huge improvement in the scripting functionality.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Michael » Sat Nov 20, 2004 2:57 am

Here is a script that will do what you want. It is more generic than you have asked for. The script will reprocess a message to handle the standard custom variable tags.

Code: Select all
{  Scan for and replace any common variable tags within a message.

{  The script can be run either against selected or outgoing messages.
{  When run against selected messages the modified message will be displayed in
{  the compose window (this is typically done from the Draft folder).
{  When run against outgoing messages the message is simply modified with CVT
{  entries replaced.

{  Author: Michael Motek, Juan de Fuca Software - www.jdfsoftware.com
{  Version 1.00 - April 3, 2002

{  Modifications:
{  20Nov2004 - M.Motek - Version 1.01
{            - Add custom tag capability.
{            - Add %PocoBuildNumber% custom tag
{            - Add %PocoVersion% custom tag

{  Read the "Content-Type" header. This header supplies information
{  about the type of message being processed (plain text or styled).
{  This information is important because you have to use different
{  PocoScript commands to read and set the body and it also determines
{  an option passed to the ReplaceCSV command.

ReadHeader $ContentType "Content-Type:" %message

{  Set the &Styled variable to indicate whether the message is styled.
{  If the content-type header contains the string "html" then we set the &Styled boolean variable to true.

Set &Styled "html" ^ $ContentType

{  The next few commands extract the text of the message. If the
{  message is styled then the styling codes are preserved.

If &Styled Then StyledMsg
   ReadBody $body %message
   GoTo ProcessCVT

:StyledMsg
   ReadRawBody $body %message
   MessageBox "Warning: At this time this script doesn't work properly for all styled messages, please use with caution.\n\nIn particular common variable tags that use quotes are not handled."

:ProcessCVT

{  Count the number of lines in the body of the message.
{  We loop through the lines from the end to the beginning this
{  allows us to ignore the possibility that as a result of the
{  processing of a command tag multiple lines may be inserted.

   LineCount #lines $body

{  The following line defines a label used in looping through all lines
{  in the body of the message.
:CVTLoop

{  Check to see if there are any lines that remain to be processed.
   If #lines < 0 Then Done

{  Get the next line from the body.
   GetLine $line #lines $body

{  Replace any builtin styling codes.
   ReplaceCVT $line %message &Styled

{  Set parameters for replacing custom tags. As of the time this
{  script was written PocoScript does not support passing parameters
{  to subroutines.
   Set $CustomTag "%PocoBuildNumber%"
   Set $ReplacementValue #PocoVersion
   Call ReplaceCustomTag

   Set $CustomTag "%PocoVersion%"
   Set $ReplacementValue $PocoVersion
   Call ReplaceCustomTag

{  Replace the line in the body of the message. This must be done
{  as a two step process, first deleting the original line, then
{  adding the replacement.
   DeleteLine $body #lines 1
   InsertLine $body #lines $line

{  Adjust the counter for the current line number.
   Dec #lines
GoTo CVTLoop

:Done

{  Replace the body of the message, again preserving styling codes.
   ClearBody %message
   If &Styled Then SaveStyledBody
      AssignBody %message $body
      GoTo Exit
:SaveStyledBody
      AssignStyledBody %message $body

:Exit
{  If the script was not invoked against a selected message then
{  exit, otherwise display the message in the compose window.
   If #PocoScriptMode ! 5 Then GetOut
   EditMessage %message

:GetOut
   Exit

{  Define the subroutine to replace custom tags.
:ReplaceCustomTag

{  Check to see if the custom tag is found in the current line.
  StringPos ##ix $CustomTag $Line

{  If not found then return to the main portion of the script.
  If ##ix = 0 Then Return

{  Replace the custom tag with the replacement value.
  CharCount ##l $CustomTag
  Set $$LineEnd $Line
  ChopString $Line ##ix 99999
  AddIntegers ##ix ##l
  Dec ##ix
  ChopString $$LineEnd 1 ##ix
  AddStrings $Line $ReplacementValue $$LineEnd
Return


As an example of how to use this message, code a message template with the following line:
Code: Select all
I am using PocoMail version %PocoVersion% (build number %PocoBuildNumber%).


Then compose a message using this template and save the message to the draft folder. Open the draft folder and then run the script against that message. (Note: The above steps are for demonstration/debug purposes, the script will act in the same manner when run on outgoing messages. I'm not sure if the script will catch custom tags in the signature, I haven't tested that).
Last edited by Michael on Tue Nov 23, 2004 4:38 pm, edited 4 times in total.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby MarkB » Sat Nov 20, 2004 4:43 am

Hi Jan and Michael.

If you wanted something really simple, you could possibly put your text into a file and use the %file% tag in your template. You could create the file manually, or create and update it automatically, for example, by having the OnStart event launch a script such as this:
Code: Select all
AppendToFile False
SaveBody $PocoVersion "C:\Program Files\PocoMail3\Signatures\PocoInfo.txt"
MarkB
Poco Enthusiast
 
Posts: 217
Joined: Mon Aug 09, 2004 1:31 am
Location: Canada

Postby janrif » Sun Nov 21, 2004 3:04 am

Michael wrote:Here is a script that will do what you want.

Before I go any further, I want to thank you for your interest in my question & the time you spent answering it.

In gen'l I don't appreciate people who come onto a forum such as this one and compare products & I'm not about to do that but I am familar w The Bat! email client having used it for a number of years. Even as a non-techie, I was able to manipulate some of The Bat's talents using macros, etc. but I found myself totally lost with Poco's approach.

Even after reading & sort of understanding how the script that you wrote works, I'm mystified why a program as elegant as Poco seems to have such a complex (to me) way of dealing with simple things. In a million years, I probably couldn' t write the script you provided & it's not for lack of interest. It's one of the things that frustrates me the most about Poco although I am a licensee.

So on the one hand, I am really appreciative of your for your reply &. on the other, I guess I'm making an observation that might be worth consideraton by aficionados & developers alike.

So again, with apologies & thanks,
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Postby Sandy » Sun Nov 21, 2004 5:56 am

Some people like SUV's and others like sports cars. It's nice to have choice. I assure you the Bat's macro facility doesn't come close to what I need.
Sandy
 

Postby janrif » Sun Nov 21, 2004 8:21 am

Sandy wrote:Some people like SUV's and others like sports cars. It's nice to have choice. I assure you the Bat's macro facility doesn't come close to what I need.

Would you explain the differences in the choice as it might be helpful in how I approach Poco. For example, what does Poco do that TB! doesn't. Thank you.
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Postby Michael » Sun Nov 21, 2004 12:58 pm

Janrif, I appreciate your comments, both in this posting and prior ones in this and other threads. What I find special about the abilities of PocoScript is it's incredible ability to deal with so many situations the author probably never dreamed of. I'll cite some examples (these are but a few of the many scripts I use):
  • At work we operate on a project basis. Our project codes consist of 8 character alphanumeric codes. My supervisor has dictated that all messages within a project begin with the project code. I wrote a script that checks the first word in each incoming and outgoing message to see if it conforms to the project code syntax. If it does then it moves the message to the mailbox for that project, creating one if necessary. This saves me creating new mailboxes each time I am assigned a new project.
  • I have a script that files messages in separate mailboxes by month and year they were received. No need to change filters every month.
  • I receive digest postings from some newsgroups. These are collections of all postings to a group for a certain period of time. I have a script that reformats each message on display to include links to the various articles from the list of messages at the start of the digest. I also insert "Previous", "Next" and "Top" links at the start of each message.
  • Someone in the forums wanted the ability to annotate messages. I wrote a script to do this. This was the predecessor to Poco's builtin annotation feature. In fact at Slaven's suggestion I made a slight modification to the script so that it would be compatible with the builtin annotation feature.
  • I have several scripts I run for advanced junk mail filtering.
  • At work we have had quite a few people retire in the past year or so. I have many messages I have received from these people. I wrote a script so that when I reply or forward one of their messages I am alerted that they have retired and am prompted as to whether or not I want to use an address of their designated replacement. I can select the replacement from a drop down list (multiple replacements supported for the situation where a person has not been replaced but their duties have been split between a number of people).


I hope this gives you an idea of the power that PocoScript provides. I'm not sure if any of these could be implemented as filters in another client, some might be but I doubt that all of them could.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Sandy » Sun Nov 21, 2004 2:35 pm

Would you explain the differences in the choice as it might be helpful in how I approach Poco.


For starters.....the ability to read ALL headers of a msg, then to parse my way thru them looking for certain conditions, then to have If....Then logic to handle msgs in various ways depending on, let's say, the finding of a specific string. Not to mention then adding my own custom header to the messasge permanently; the data from which I can display in the index pane since I can customize the columns adding my custom header's data to the normal "Sent", "Recieved", "To", etc columns.
Sandy
 

Postby janrif » Mon Nov 22, 2004 9:50 am

Michael wrote:I hope this gives you an idea of the power that PocoScript provides.

Yes it certainly does & it's overwhelming. I guess I have at least two problems:

1. enough imagination to find tasks for PocoMail to do for me that it's not already doing.

2. figure out the best way to appoach the task.

I think I'll start with the first one first & then read some more but just to illustrate the depth of my ignoranance you provided me with a script to do what I asked but I can't figure out how to implement it.

I guess it's via events, i.e. attach event to outgoing mail addressed to specific addresses or whatever.

Appreciate your patience & admire your talent, Michael. I'll keep trying & come back when I've done some homework.

Thanks.
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Postby janrif » Mon Nov 22, 2004 9:55 am

Sandy wrote:
Would you explain the differences in the choice as it might be helpful in how I approach Poco.

[snip] the ability to read ALL headers of a msg, then [snip] to have If....Then logic to handle msgs in various ways [snip] then adding my own custom header [/snip]

Sandy, thanks for your reply. Could you give me a practical example of why you would want a custom header/column? I understood the rest of it in my own superficial way.

Thank you.
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Postby Sandy » Mon Nov 22, 2004 11:20 am

My ISP includes X-headers that indicate how the msg fails some of its spam tests. I count these headers up and report the number of them and their type in the index pane for the msg. This both marks such msgs for my investigation, and informs me how I might instruct my ISP to autoimatically reject msgs as spam in the future if they trigger more than one of these criteria.

Of the 100-150 spams I used to get per day, using this technique I am now down to 1 or 2.
Sandy
 

Postby janrif » Mon Nov 22, 2004 1:48 pm

Sandy wrote:My ISP includes X-headers that indicate how the msg fails some of its spam tests. I count these headers up and report the number of them and their type in the index pane for the msg. This both marks such msgs for my investigation, and informs me how I might instruct my ISP to autoimatically reject msgs as spam in the future if they trigger more than one of these criteria.

Of the 100-150 spams I used to get per day, using this technique I am now down to 1 or 2.

I guess you've created something like pre-emptive baysian filtering. Pretty neat. How do you check for false/positives or is that not a problem? TIA
janrif
Ridgefield, CT USA
w2k-sp4
janrif
Resident Poster
 
Posts: 111
Joined: Mon Aug 30, 2004 11:53 pm
Location: CT, USA

Next

Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron