[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 - SaveMessageDialog

SaveMessageDialog

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

SaveMessageDialog

Postby adsworth » Tue Sep 27, 2005 12:58 am

Hi,

thanks to the help from Eric pointing me in the right direction, here is my first script.

Code: Select all
{  Script: SaveMessageDialog
{  Created: 2005/09/25
{  Author: Adi J. Sieker
{  Mode: This script is designed to run from a button click.
{  Purpose: Save a message to a specified mailbox.
{  Description:
{  When executed the script displays a messagebox in which the user
{  can enter a mailbox name to save the mail to.
{  If sender email is in the contacts, the script will prefill the
{  dialog with the value from the first custom field.
{  So you can predefine a mailbox in each contact, to which
{  email from that person will per default be saved to.
{  If the mailbox name entered in the dialog doesn't exist, it
{  is autmatically created and the mailboxes are refreshed.
{  This allows me to save a message to a per contact
{  predefined mailbox in 2 keystrokes. Ctrl+1 and <ENTER>.

Set $OnErrorGoTo "ErrorHandler"

Set $defBox ""

{read the sender of the mail}
ReadHeader $from "From:" %message
ExtractEMail $from
CharCount #n $from
{if we don't have a recipient jump to the selection dialog}
If #n = 0 Then RequestMailBox

{read a mailbox name from the first custom field}
GetAddressField $defBox $from "customdata1"

:RequestMailBox
InputBox $mailBox "Select mailbox %mailboxes%" $defBox

{check wether the user entered or selected some text.}
{if not then jump to the end of the script}
CharCount #n $mailBox
If #n ! 1 Then Endcript

{check wether the mailbox we saved to exists}
LinePos #mailBoxExists $mailBox %mailboxes%

{save the message in the specified mailbox and}
{delete the original mail}
SaveMessage %message $mailBox
DeleteMessage %message

{if the mailbox we saved to didn't exist}
{reload the mailboxes}
If #mailBoxExists ! -1 Then EndScript

RefreshMailboxes


:ErrorHandler

:EndScript
  Exit


Feedback welcome
Adi
adsworth
Drop-in Visitor
 
Posts: 14
Joined: Fri Sep 23, 2005 2:49 am

Postby Michael » Tue Sep 27, 2005 1:43 pm

One suggestion for a change and a note of caution as well:

First, the suggested change, change the "Set $defBox """ line to:
Code: Select all
External $defBox "Default mailbox %mailboxes%" ""


This will allow people to select a default mailbox using the "Script Setup" tab.

Now the caution, if people have selected a portion of the text in the message then that is all that will be saved, all other text in the body will be lost. There are discussions currently underway regarding how to address this in the next major release.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby adsworth » Thu Sep 29, 2005 7:47 am

Michael wrote:One suggestion for a change and a note of caution as well:

First, the suggested change, change the "Set $defBox """ line to:
Code: Select all
External $defBox "Default mailbox %mailboxes%" ""


This will allow people to select a default mailbox using the "Script Setup" tab.

Yes, that's an idea. I was doing the Set defBox so that it would always be initialized and I wouldn't get an error.

Michael wrote:Now the caution, if people have selected a portion of the text in the message then that is all that will be saved, all other text in the body will be lost. There are discussions currently underway regarding how to address this in the next major release.

Thanks, for that info. Even though I know about it, it already happened to me...
IMHO, if you call something %message% it should always contain the complete message. If the possibility to just process the select text then introduce a variable %selectedtext% or something similiar.

Thanks
adi
adsworth
Drop-in Visitor
 
Posts: 14
Joined: Fri Sep 23, 2005 2:49 am

Postby Michael » Thu Sep 29, 2005 3:53 pm

adsworth wrote:
Michael wrote:Now the caution, if people have selected a portion of the text in the message then that is all that will be saved, all other text in the body will be lost. There are discussions currently underway regarding how to address this in the next major release.

Thanks, for that info. Even though I know about it, it already happened to me...
IMHO, if you call something %message% it should always contain the complete message. If the possibility to just process the select text then introduce a variable %selectedtext% or something similiar.

Thanks
adi


The problem with doing this at this stage is that it would break existing scripts. It would be much easier to identify the scripts at risk by scanning for the SaveMessage command rather than changing the current functionality of the %Message variable and introducing a %SelectedText variable, if that were done it would be next to impossible to detect which existing scripts needed to be modified to use the %SelectedText variable.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby adsworth » Thu Sep 29, 2005 11:50 pm

Michael wrote:
adsworth wrote:
Michael wrote:Now the caution, if people have selected a portion of the text in the message then that is all that will be saved, all other text in the body will be lost. There are discussions currently underway regarding how to address this in the next major release.

Thanks, for that info. Even though I know about it, it already happened to me...
IMHO, if you call something %message% it should always contain the complete message. If the possibility to just process the select text then introduce a variable %selectedtext% or something similiar.

Thanks
adi


The problem with doing this at this stage is that it would break existing scripts. It would be much easier to identify the scripts at risk by scanning for the SaveMessage command rather than changing the current functionality of the %Message variable and introducing a %SelectedText variable, if that were done it would be next to impossible to detect which existing scripts needed to be modified to use the %SelectedText variable.


That is true. It all depends on, if you want to stay compatible with the current behaviour or not. If the current behaviour is thought of as needed to not brak existing script, a new variable %mail or whatever will have to be introduced, I guess. :)

adi
adsworth
Drop-in Visitor
 
Posts: 14
Joined: Fri Sep 23, 2005 2:49 am


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron