[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 - Highlight on display?

Highlight on display?

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Highlight on display?

Postby SaskiasImp » Tue Feb 22, 2005 12:26 pm

Is it possible to highlight certain words in all emails when they are viewed (without actually changing the emails)? If so would it be possible to have a list of words that are highlighted? Could different colors be used for highlighting?

I'm just looking into scripting in pocomail for the first time and couldn't find any leads into this area. Most of the words i would be looking for will be within links in plain text emails.

thanks for any help.
SaskiasImp
Poco Tourist
 
Posts: 16
Joined: Mon Feb 07, 2005 10:21 am

Postby Michael » Tue Feb 22, 2005 3:07 pm

Yes, you could do this. You would need to use an OnDisplay event to trigger the script. This is one of the few types of events that does not alter the message in the mailbox, just the content that is displayed.

In order to accomplish what you want you would have to convert the message to styled and insert tags around the words you want to highlight.

I use a similar approach to add links to email digests from news groups. This allows me to link directly to the articles and to return to the table of contents from an article without having to scroll.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

That sounds intresting

Postby tryforsure » Thu May 18, 2006 12:48 am

Hi Micheal

That sounds neat could you post an example script please.

Cheers
tryforsure
Drop-in Visitor
 
Posts: 9
Joined: Sun Dec 18, 2005 10:24 pm
Location: Scotland

Postby Michael » Thu May 18, 2006 3:16 am

I don't have an example right at hand, the following is "aircode", untested and I'm not even sure it is syntactically correct. There are still significant sections of the script that need to be coded. This is only a sample to help get you started.
Code: Select all
External $UserFile1 "List of words/phrases to highlight" "highlight_words.txt"
External $HighlightColor_Start "Highlight color/style - html coding" "<b><i>"
External $HighlightColor_End "Highligh color end coding" "</i></b>"

ReadBody $Highlighted_Words $UserFile1
LineCount #Highlighted_Words $Highlighted_Words
Set #WordCounter 0

{  Note: You will have to check for styled messages and handle them differently if you want to preserve styling

ReadBody $Body %Message

:WordLoop
GetLine $Word #WordCounter $Highlighted_Words

{  Case sensitive search, requried because the StringPos function is case sensitive.
LocateLine #IX $Word $Body True
If #IX < 0 Then NextWord

{  Extract line, add styling and replace line

GetLine $Line #IX $Body
StringPos #JX $Word $Line

Set $Prefix $Line
ChopString $Prefix #JX 9999
ChopString $Line 1 #JX
AddStrings $Prefix $HighlightColor_Start $Word $HighlightColor_End $Line

DeleteLine $Body #IX 1
InsertLine $Body $IX $Prefix

{  Search for next occurrence of the word.
{ Note: You will have to ignore all occurences you have already processed.

You need to add code here.


:NextWord
Inc $WordCounter
If #WordCounter < #Highlighted_Words Then WordLoop

You will need to add code here to replace the current message body with the new one the script has just built.

Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby tryforsure » Thu May 18, 2006 7:31 am

Great!

Yes micheal that looks excellent.:D i'll have a bash at it tonight!


Thanx
tryforsure
Drop-in Visitor
 
Posts: 9
Joined: Sun Dec 18, 2005 10:24 pm
Location: Scotland

Postby tryforsure » Thu May 18, 2006 10:51 am

Hey that template was excellent

this seems to do it! i have set this to run with the on display event
just have to work out how to disply the diferent styles and colours!

Thanx very Much. :D

Any feedback appreciated!

Code: Select all
External $UserFile1 "List of words/phrases to highlight" "highlight_words.txt"
External $HighlightColor_Start "Highlight color/style - html coding" "<b><i>"
External $HighlightColor_End "Highligh color end coding" "</i></b>"

AppendToFile True

OpenBody $Highlighted_Words $UserFile1
LineCount #Highlighted_Words $Highlighted_Words
Set #WordCounter 0

{  Note: You will have to check for styled messages and handle them differently if you want to preserve styling}

ReadBody $Body %Message

:WordLoop
GetLine $Word #WordCounter $Highlighted_Words

{  Case sensitive search, requried because the StringPos function is case sensitive.}

Set $tmpBody $Body

Set #LX 0

:BodyLoop

LocateLine #IX $Word $tmpBody True
If #IX < 0 Then NextWord
{  Extract line, add styling and replace line }

GetLine $Line #IX $tmpBody

call LineLoop

AddIntegers #LX #IX

DeleteLine $Body #LX 1
InsertLine $Body #LX $Line

Inc #LX
Inc #IX

DeleteLine $tmpBody 0 #IX

goto BodyLoop


{  Search for next occurrence of the word.
{ Note: You will have to ignore all occurences you have already processed.
{You need to add code here.}

:NextWord
Inc #WordCounter
If #WordCounter < #Highlighted_Words Then WordLoop

AssignBody %Message $Body
{ You will need to add code here to replace the current message body with the new one the script has just built.}
Exit


{ a sub-routine to parse the line looking for occurences of word then change}
{  }
{  }
:LineLoop
Set $Rebuilt ""

:Loop
StringPos #JX $Word $Line

If #JX <1 Then NextL
Set $Prefix $Line
ChopString $Prefix #JX 9999
Dec #JX
ChopString $Line 1 #JX
SubStrings $Line $Word
AddStrings  $Rebuilt $Prefix $HighlightColor_Start $Word $HighlightColor_End
goto Loop

:NextL
AddStrings $Rebuilt $Line
Set $Line $Rebuilt
return
tryforsure
Drop-in Visitor
 
Posts: 9
Joined: Sun Dec 18, 2005 10:24 pm
Location: Scotland

Postby tryforsure » Thu May 18, 2006 1:10 pm

Here is updated one with some colur in it
A bit better nicer to look at!
It may have some problems with html files


Code: Select all
{to get colour and stuff goto the setup script button and put }
{ur formatting including colour tags which i think is font ie }
{ put this <font color="#0000FF"> in the html }
{ coding box and </font> in the html end box. }

{version 0.2}

External $UserFile1 "List of words/phrases to highlight" "highlight_words.txt"
External $HighlightColor_Start "Highlight color/style - html coding" "<b><i><font color=\"#0000FF\" > "
External $HighlightColor_End "Highligh color end coding" "</font></i></b>"

AppendToFile True

OpenBody $Highlighted_Words $UserFile1
LineCount #Highlighted_Words $Highlighted_Words
Set #WordCounter 0

{  Note: You will have to check for styled messages and handle them differently if you want to preserve styling}

ReadBody $Body %Message

:WordLoop
GetLine $Word #WordCounter $Highlighted_Words

{  Case sensitive search, requried because the StringPos function is case sensitive.}

Set $tmpBody $Body

Set #LX 0

:BodyLoop

LocateLine #IX $Word $tmpBody True
If #IX < 0 Then NextWord

{  Extract line, add styling and replace line }
GetLine $Line #IX $tmpBody

{jump to the sub-routine}
call LineLoop

AddIntegers #LX #IX

DeleteLine $Body #LX 1
InsertLine $Body #LX $Line

Inc #LX
Inc #IX

DeleteLine $tmpBody 0 #IX

goto BodyLoop


{  Search for next occurrence of the word.
{ Note: You will have to ignore all occurences you have already processed.
{You need to add code here.}

:NextWord
Inc #WordCounter
If #WordCounter < #Highlighted_Words Then WordLoop

{quick test to insert some tags}
InsertLine $Body 0 "<body>"
InsertLine $Body 0 "<html>"
LineCount #IX $Body
{insert line breaks}
call InsertLineBreaks
Inc #IX
InsertLine $Body #IX "</body>"
InsertLine $Body #IX "</html>"
{quick test ends}

AssignStyledBody %Message $Body
{ You will need to add code here to replace the current message body with the new one the script has just built.}
Exit

{************************************************************************************)
{ a sub-routine to parse the line looking for occurences of word then change}
{  }
{  }
:LineLoop
Set $Rebuilt ""

:Loop
StringPos #JX $Word $Line

If #JX <1 Then NextL
Set $Prefix $Line
ChopString $Prefix #JX 9999
Dec #JX
ChopString $Line 1 #JX
SubStrings $Line $Word
AddStrings  $Rebuilt $Prefix $HighlightColor_Start $Word $HighlightColor_End
goto Loop

:NextL
AddStrings $Rebuilt $Line
Set $Line $Rebuilt
return

{ *************************************************************************************}
{ another sub-routine to insert line breaks into the body of the text }
{ }
{ }
:InsertLineBreaks
{sstart tx at 2 to miss the html and body lines}
Set #TX 2

:LoopHere
GetLine $Line #TX $Body
AddStrings $Line "<br>"
DeleteLine $Body #TX 1
InsertLine $Body #TX $Line
Inc #TX
If #TX < #IX Then LoopHere

return
tryforsure
Drop-in Visitor
 
Posts: 9
Joined: Sun Dec 18, 2005 10:24 pm
Location: Scotland

Postby Michael » Thu May 18, 2006 1:48 pm

Just a note, you can use the Setup Script tab in the scripts editor to configure the styles and colors you want to use.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 0 guests

cron