count of messages in and outside a function

As an applescript novice, I’m having some trouble … perhaps someone can help me out:

set Y to thisMailbox
display dialog count of messages of mailbox Y

on thisMailbox
display dialog count of messages of mailbox X
return X
end thisMailbox

Howcome this does not work?

Hi,

I’m going to sleep right now, but perhaps you might want to state what you think should happen because there are several things. You can read the AppleScriptLanguageGuide.pdf also. Some important things are how to call subroutines, how to reference objects maybe.

Edit: also about variables.

Edit: also tell statements.

goodnight,

Earlier today, after posting the message, I found the reference manual you mentioned. I tried to find an answer to my question by searching through the manual. No luck right now. I will try some more later on today …

Anyway, what I’m trying to do is this:
I want to call this function with a string parameter containing the name of a mailbox I am looking for in Mail.app, I want the function to return that mailbox to me in such a way that I can use it like I would within that function.

Ultimately, this function will be used in an Applescript that sets out to move selected messages to an existing folder named after their respective sender. It seems several people other people have been working on similar scripts, like mchang and Aaron Swartz but they made their scripts differently from what I’m setting out to do.

As this is my first AppleScript project, I’m dealing with the problem in segments. One part get the senders address from a message, another looks up the ‘real name’ of this user in Address Book, this part is supposed to look up the folder with a name equal to the real name of that user … when I bind it all together, it will move the message to that folder.

I’m not sure what you’re trying to do but perhaps this will help:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]