[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 - Very basic script question

Very basic script question

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

Very basic script question

Postby SFCurley » Wed Aug 11, 2004 9:10 am

I'm trying to write my first real Poco Script, but am running into an apparently dumb-user problem, but I just can't see it:

Here's the first few lines of the script (that aren't working):

MessageBox %message
ReadHeader $subject "Subject:" %message
MessageBox $subject

Exit

I'm running this in debug mode with "Run on Selected Messages" with a message selected in my "To Read" folder. I would expect to see the message displayed in a message box and then the subject in another message box. Instead I get empty message boxes (actually the first msg box says "%message", and second is empty.

1) What am I missing here?

2) Some of the script functions (getline) say they are 0-based (vs. 1-based). What does this mean in practice? If a file has 1 line, and I do a line count, what would it be if 0-based (or if 1-based)?

Thanks much.
SFCurley
 

Postby Hogyt » Wed Aug 11, 2004 10:40 am

Hi,

1) Think of %message as a pointer or handle to the current message rather than the message itself so to get the body of the message use ReadBody (or ReadRawBody) eg.

ReadBody $m %message

And then you can display it with

MessageBox $m

I think %message isn't set when running in debug mode so you'll have to save the script and run it normally eg. from the All Scripts Run menu.

2) If you do a linecount it will literally tell you the number of lines in the string you give it eg. if it has 10 lines it'll give you 10 (thats 1-based). Then if you use getline to extract these lines you'll have to reference them from 0 to 9 (thats 0-based).

Hope that helps and i'm sure one of the gurus will correct me if i'm wrong!
Mat
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby SFCurley » Wed Aug 11, 2004 11:00 am

Excellent. Tried it and it worked just as you said.

Also, after I ran the script once from the "All Scripts" menu, I was then able to run the script in debug mode and it seemed to maintain the message informatin.

After I selected a different message, it went back to being blank.

Thanks for you help, Mat.
SFCurley
 

Postby Hogyt » Wed Aug 11, 2004 11:05 am

Thats great! I hope you enjoy Pocoscript. It's amazing what a relatively small language can achieve :D
Hogyt
Poco Enthusiast
 
Posts: 241
Joined: Thu Jul 29, 2004 11:22 am
Location: England

Postby Michael » Wed Aug 11, 2004 1:13 pm

A couple of points here:
  • You must save the script before you run it.
  • When the "Debug run" button is used the %message variable is not set by PocoScript
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 3 guests

cron