[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 - Printing the selected part of a message

Printing the selected part of a message

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Printing the selected part of a message

Postby frazmi » Mon Aug 02, 2004 2:20 am

I've often wanted to print just the "selected text" in a message, but nothing seems to be available in Poco. Here's a tiny script that gets about 80% of the way there.

This may actually work due to a "bug" (or at least an undocumented feature) in PocoScript -- I do not recall ever seeing this documented. The script works because ReadBody, at least in versions 3 and 3.1 of Poco, will return the selected portion of the body if any selection has been made, and returns the entire body if no selection is made.

Obviously, you can insert your favorite word processor or print routine. And if you have a program that will print with a command line parameter, you could automate the whole thing. (I do not believe that Word has a documented switch to do this.) In addition, I've hard-coded the file location and names -- a more advanced version might be more flexible. This is just a proof of concept.

BTW, one easy way to handle the running of this script is to assign it to one of the custom buttons (1-10). And finally, my standard "warranty" applies -- it works on my system. Here's the script:
Code: Select all
Set $OnErrorGoTo "POCO_ERROR"

Set $Spooler "E:\Test"
Set $slash \
AddStrings $Spooler $slash "Spooler.spool"

ReadBody $body %message
DeleteFile $Spooler
SaveBody $body $Spooler

Execute winword $Spooler

EXIT
frazmi
Poco Enthusiast
 
Posts: 248
Joined: Tue Jul 27, 2004 1:27 am
Location: South Korea

Re: Printing the selected part of a message

Postby Pete » Wed Aug 04, 2004 12:30 pm

frazmi wrote:This may actually work due to a "bug" (or at least an undocumented feature) in PocoScript -- I do not recall ever seeing this documented.

I've also encountered this behavior in the past and I don't like it because I think that it's too dangerous. That is, if a person uses any PocoScripts, then the SaveMessage command will only save the selected text of the message (instead of the entire message) and it's unlikely that a user would notice this until it's too late.
Pete
 

Postby frazmi » Wed Aug 04, 2004 3:14 pm

What would you say to a new optional argument to ReadBody called "&AlwaysGetEntireBody"? If TRUE, the function would ignore the selection (if any) and return the entire message body. If FALSE, the function would work as it does now.

For true backward compatibility, it should default to FALSE, but could be set to TRUE to prevent the problem you mention.
frazmi
Poco Enthusiast
 
Posts: 248
Joined: Tue Jul 27, 2004 1:27 am
Location: South Korea

Postby Michael » Wed Aug 04, 2004 4:05 pm

frazmi wrote:What would you say to a new optional argument to ReadBody called "&AlwaysGetEntireBody"? If TRUE, the function would ignore the selection (if any) and return the entire message body. If FALSE, the function would work as it does now.

For true backward compatibility, it should default to FALSE, but could be set to TRUE to prevent the problem you mention.


The behaviour of passing only the selected portion of the text is one that I have used in a number of scripts. I'm not sure what the best solution is, Pete has a valid point regarding possible problems with the current implementation but I know of a few scripts that will stop working as advertised should this behaviour be changed.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby Pete » Wed Aug 04, 2004 5:24 pm

Well, guys, I would like all of the PocoScript commands (including the ReadBody/ReadRawBody commands) to work with the entire message by default. This is intuitive. I believe that the current behavior that happens after a user has selected text in the Preview Pane is unexpected, unintuitive, undocumented, and un-user-friendly. :)

We also have to consider the PocoMail users who will never write a PocoScript themselves but who use other people's scripts such as those in the Extras section of the website. Those people should never have to worry about whether or not they've selected text in the Preview Pane before they run our PocoScripts. It will never occur to them that PocoScripts work differently depending on whether or not they have selected some text in the Preview Pane.

I think that the behavior is dangerous even for experienced PocoScripters. It's too easy to click a toolbar button that runs a script without realizing that I've previously selected some text in the Preview Pane. It's also possible that the selected text in the Preview Pane is not currently visible because that part of the message has been scrolled out of sight with the scrollbar.

I think that Michael and I agree in general and I think that we both want what's best for both expert and novice users of PocoMail. My opinion possibly differs from his because I think that the %message variable should always work with the entire message and that people who have been using the undocumented behavior should be asked to do a search-and-replace on their scripts and change all occurrences of the %message variable (where they use the undocumented behavior) to a new one such as %selectedTextMessage. I don't think that it's fair to ask the majority of PocoScript programmers to change our scripts just because some people are using the undocumented behavior.

Michael, I wonder how many changes would be required for people who are using the current behavior. It seems to me that the current behavior would only be useful in a small number of situations and that it would be relatively easy for them to change their scripts to handle these special situations. What do you think?
Pete
 

Postby frazmi » Wed Aug 04, 2004 6:03 pm

Pete wrote
I don't think that it's fair to ask the majority of PocoScript programmers to change our scripts just because some people are using the undocumented behavior.
As far as I can tell, nobody so far has suggested this. If the existing readbody function were modified as I suggested (by adding a new optional parameter), every script currently in existence would continue to function exactly as it does now. Thus, if the [bug | undocumented behavior | whatever] currently causes a problem if there's selected text in the preview pane, it would continue to cause problems.

Having said that, I also like the idea of a new variable construct, %SelectedTextMessage. I don't know which would be more difficult to implement, nor which might have more side effects, but I would be satisfied with either solution.
frazmi
Poco Enthusiast
 
Posts: 248
Joined: Tue Jul 27, 2004 1:27 am
Location: South Korea

Postby Michael » Thu Aug 05, 2004 2:29 am

Pete wrote:Well, guys, I would like all of the PocoScript commands (including the ReadBody/ReadRawBody commands) to work with the entire message by default. This is intuitive. I believe that the current behavior that happens after a user has selected text in the Preview Pane is unexpected, unintuitive, undocumented, and un-user-friendly. :)

We also have to consider the PocoMail users who will never write a PocoScript themselves but who use other people's scripts such as those in the Extras section of the website. Those people should never have to worry about whether or not they've selected text in the Preview Pane before they run our PocoScripts. It will never occur to them that PocoScripts work differently depending on whether or not they have selected some text in the Preview Pane.

I think that the behavior is dangerous even for experienced PocoScripters. It's too easy to click a toolbar button that runs a script without realizing that I've previously selected some text in the Preview Pane. It's also possible that the selected text in the Preview Pane is not currently visible because that part of the message has been scrolled out of sight with the scrollbar.

I think that Michael and I agree in general and I think that we both want what's best for both expert and novice users of PocoMail. My opinion possibly differs from his because I think that the %message variable should always work with the entire message and that people who have been using the undocumented behavior should be asked to do a search-and-replace on their scripts and change all occurrences of the %message variable (where they use the undocumented behavior) to a new one such as %selectedTextMessage. I don't think that it's fair to ask the majority of PocoScript programmers to change our scripts just because some people are using the undocumented behavior.

Michael, I wonder how many changes would be required for people who are using the current behavior. It seems to me that the current behavior would only be useful in a small number of situations and that it would be relatively easy for them to change their scripts to handle these special situations. What do you think?


A quick scan of my scripts reveals I have 10-12 that rely on the selected text being passed to the %Message variable. I have not done a scan of the scripts in the extras area to see which ones use this feature.

I have, in the past, asked Slaven to create a %FullMessage system variable because there have been times when I'd like to know whether or not the user has selected a portion of the message.

The problem, as I see it, is that changing current behaviour may not be ideal. There may be people out there who have scripts installed on their system that are using this feature. If the ReadBody command were to change then their scripts would stop working as desired and they wouldn't necessarily know why. It could cause problems for them (suppose their business relied on this feature for some purpose).
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Just encountered this myself

Postby bulbous » Wed Jun 28, 2006 10:29 am

I just ran into a problem with filing a message -- I couldn't figure out why I couldn't find this message I was sure I had received, and it turns out that when I used a button script to file it to a saved folder, I must have had some text selected, as part of the message is there.

Is there any way to move a message from one folder to another without only copying the selected text? I've looked everywhere and can't find anything -- seems like such a trivial need that I must just be missing it.

Now, obviously I can right click a message and use the "Move to Folder" submenu, but I've got a couple buttons that I use to run a script -- for commonly used folders that I file stuff to.
bulbous
Drop-in Visitor
 
Posts: 7
Joined: Mon Apr 10, 2006 3:51 pm

Postby Michael » Wed Jun 28, 2006 1:24 pm

Not while using a script, see my alternate method in this thread.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

hmm

Postby bulbous » Wed Jun 28, 2006 3:09 pm

I can't see your alternate solution anywhere in the thread -- there's a mention of a %fullmessage variable -- but that doesn't appear to be implemented yet. -- I've read the thread 3 times now (your messages Michael, more) -- but the only thing I've seen anywhere on the boards suggests right-clicking a message -- I'd like to make buttons for my most common filters... (being able to add a filter to the hotbar would work just fine for me too)
bulbous
Drop-in Visitor
 
Posts: 7
Joined: Mon Apr 10, 2006 3:51 pm

Postby Michael » Wed Jun 28, 2006 5:24 pm

My alternate solution was posted at Wed Jun 28, 2006 5:21 pm. It suggests using manual filter groups. To the best of my knowledge you cannot assign these to a button but you can use keyboard shortcuts to execute them.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada

Postby bulbous » Thu Jun 29, 2006 7:12 am

ok -- I'm stupid -- first off I didn't notice that "This Thread" was a link -- and I somehow didn't realize there was a reply to my question in the other thread. Thanks for the info -- still hoping they'll make a %fullmessage available, or buttonable filters.
bulbous
Drop-in Visitor
 
Posts: 7
Joined: Mon Apr 10, 2006 3:51 pm


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 3 guests

cron