Domanda

Someone please help me here and show me how to get this to work. I've checked examples on returning values from functions with this AppleScript, but something I am missing here.

I'm trying to get the function, strTest(), to pass a string that will then be printed to the BBEdit editor. If I were to replace the variable with a static string, that works. But this isn't working at all. I'm getting: "The variable theText is not defined."

Does anybody see what's going on?

on strTest()
    set returntest to "this is a test"
    return returntest
end strTest

tell application "BBEdit"
    set theText to strTest()
    tell window 1
        set insertionP to get selection
        set text of insertionP to (theText & (text of insertionP))
    end tell
end tell
È stato utile?

Soluzione

If you are going to call a handler from within an application's tell block, use the my reserved word in front of the handler, e.g.:

set theText to my strTest()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a apple.stackexchange
scroll top