Title: Re: Another "simple" AppleScript Question
On 8/11/02 1:31 PM, "Peter Wait" <[EMAIL PROTECTED]> wrote:

I’d like to be able to find the size of my contact’s Description field (to treat short descriptions differently from long ones).  So I’ve read up on, I really have, the Data Size command and the Count Number of Characters command. And I can’t get either to work.

With the Data Size, I first set theNotes to the contract’s Description, and then say:

if ((data size of theNotes) < 26) then

I then get the error message, “Microsoft Entourage got an error: <... it then correctly repeats the contents of my Description...>” doesn’t understand the data size message.”

The book says it should return the size in bytes, which should give the same answer as Count the Number of characters. I’d settle for either.

This has got to truly be simple, and I already feel I should have been able to figure it out myself.

So thanks again for your patience,

    Peter

Nope, this time you picked one that doesn't work that way, and is poorly documented to boot. Good question. The only hint you might have of it is that 'data size' is part of (Apple's) Standard Suite, not part of Entourage's own custom Suites. So it's not likely to work with Entourage's own defined properties of its own classes, but more likely just with classes themselves. I've only ever found it to work with messages, in fact (I'm nit certain, but it might work with attachments too). It doesn't work with folders, nor with anything else, as far as I know. Someone else might know of something else it works with.

But you're just talking about TEXT here: just get the length of the text, or count it. (Counting is minutely faster, but you have to be careful to use parentheses usually.)

Either of these will work:

    set theNotes to description of theContact
    set noteLength to length of theNotes

or

    set theNotes to description of theContact
    set noteLength to (count theNotes)

Of course if you're in a 'tell theContact' block, you don't use 'of theContact'.

The result will tell you how many characters long the notes are. (In a text application that would be the same as the number of bytes, if plain text. That quite possibly does not apply here.). So

    if  noteLength  > 200 then
        set theNotes to text 1 thru 199 of theNotes & "…"
    end if


or whatever you're planning to do.
    

--
Paul Berkowitz

Reply via email to