Re: AppleScript: How to access note contents?

2007-05-23 Thread Jim DeVona

On 5/23/07, Jim Correia <[EMAIL PROTECTED]> wrote:


...

To solution in this situation (when you've got a specifier stored in
a variable) is to use the double contents of syntax:

 set s to contents of contents of variableName

Jim


On 5/23/07, Adrian <[EMAIL PROTECTED]> wrote:


Yes, this one caused no no end of pain. What you want is

  set _text to contents of contents of _item

Killer, huh? I think contents must be some sort of reserved word.


Thank you both for the solution, Adrian and Jim. The AppleScript
information is useful, too.

Thanks again,
Jim

--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: AppleScript: How to access note contents?

2007-05-23 Thread Jim Correia

On May 22, 2007, at 10:35 PM, Jim DeVona wrote:


Can someone help me figure out how to access note text with
AppleScript? Here is a contrived example of what I'm trying to do:

tell application "Yojimbo"
	set _item to make new note item with properties {name:"Foo",  
contents:"Bar"}

set _text to contents of _item
end tell

I'd like to assign the "Bar" contents to the _text variable, but it
just gets another reference to the note item. I don't actually need to
put it all in a variable;


According to the Scripting Guidelines:

If an object’s contents can be represented as a single value, it
should define a contents property. For example, documents in a word
processor would define a contents property that returned all the
text as a string. contents is usually writable.

For this reason, Yojimbo note items have a property named "contents".

The problem you are running into is because you have a variable which  
contains a reference (specifier) to the note item.


AppleScript treats "contents of" specially when operating on variables.

set x to 3
contents of x
-- 3

If x is a reference/specifier to an object, then sometimes  
AppleScript will automatically dereference the variable for you.


tell application "Script Editor"
set d to document 2
name of d
-- "My Fancy Script"
name of contents of d
-- "My Fancy Script"
end tell

But AppleScript doesn't do the implicit dereferencing when asking for  
the contents property (because of the semantics in the first example.)


tell application "Script Editor"
set d to document 2
name of d
-- "My Fancy Script"
contents of d
	-- AppleScript asks the script editor for `document 2`, and it  
returns

-- document 2 of application "Script Editor"
contents of contents of d
	-- AppleScript asks the script editor for `contents of document  
2`, and it returns

-- the text content of the document
contents of document 2
	-- AppleScript asks the script editor for `contents of document  
2`, and it returns

-- the text content of the document
end tell

This "conflict" between the contents property and the contents of  
operator can be confusing.


To solution in this situation (when you've got a specifier stored in  
a variable) is to use the double contents of syntax:


set s to contents of contents of variableName

Jim


--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working
correctly? Please send mail to: <[EMAIL PROTECTED]>


Re: AppleScript: How to access note contents?

2007-05-23 Thread Adrian

Hi Jim,

Yes, this one caused no no end of pain. What you want is

set _text to contents of contents of _item

Killer, huh? I think contents must be some sort of reserved word.

Adrian



On May 23, 2007, at 2:35 pm, Jim DeVona wrote:


Can someone help me figure out how to access note text with
AppleScript? Here is a contrived example of what I'm trying to do:

tell application "Yojimbo"
	set _item to make new note item with properties {name:"Foo",  
contents:"Bar"}

set _text to contents of _item
end tell

I'd like to assign the "Bar" contents to the _text variable, but it
just gets another reference to the note item. I don't actually need to
put it all in a variable; I'm just trying to access the text so that I
can do 'set first word to "hello"' type manipulations.

Thanks,
Jim

--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working  
correctly? Please send mail to: <[EMAIL PROTECTED]>



--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>


AppleScript: How to access note contents?

2007-05-22 Thread Jim DeVona

Can someone help me figure out how to access note text with
AppleScript? Here is a contrived example of what I'm trying to do:

tell application "Yojimbo"
set _item to make new note item with properties {name:"Foo", 
contents:"Bar"}
set _text to contents of _item
end tell

I'd like to assign the "Bar" contents to the _text variable, but it
just gets another reference to the note item. I don't actually need to
put it all in a variable; I'm just trying to access the text so that I
can do 'set first word to "hello"' type manipulations.

Thanks,
Jim

--
--
This message is sent to you because you are subscribed to
 the mailing list .
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  
Have a feature request, or not sure if the software's working 
correctly? Please send mail to: <[EMAIL PROTECTED]>