Difference between variable and pipe to shell in applescript 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 &gt; ~/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.
There is a hidden error that is generated when you run your "working" script... You have to bump the shell script part of the code into its own tell current application block as shown in the second example below...

This version works for me with creating a TextEdit document:

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
    end tell
    tell application "TextEdit"
        activate
        make new document with properties {name:"KeynoteNotes.txt"}
        set text of front document to presenterNotes
    end tell
end tell


The shell pbpaste version with proper blocking to avoid error -10004:

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
    end tell
    tell current application
        do shell script "pbpaste &gt; ~/keynote-notes1.txt"
    end tell
end tell