In answering this question I wrote this script:
global presenterNotes
tell application "Keynote"
activate
open (choose file)
tell front document
set presenterNotes to presenter notes of every slide as text
set the clipboard to presenterNotes
do shell script "pbpaste > ~/keynote-notes.txt"
end tell
quit application "Keynote" end tell
My question is: in the instance above when I replace the "shell script" statement with the statement below why does this statement work:
tell application "TextEdit"
activate
make new document
set text of front document to presenterNotes
quit application "TextEdit"
end tell
Example 1: but this one does not:
tell application "TextEdit"
activate
make new document with data presenterNotes as text
Example 2: nor does:
make new document with presenterNotes
I know there are other ways to make it work like copy to clipboard and then issue a command+c.
I would like to understand why the global variable is not being transferred to the textEdit document, in particular in Example 1 above, as applescript does not throw an error.