Search code examples
applescript

Remove annoying "OK"'s from the output of applescript?


I'm trying to read a string using AppleScript from the command line.

I have the following script:

on run prompt
    set theResponse to display dialog prompt default answer ""
    --> {text:"Jen"}
    return (text of theResponse)
end run

Which seems to work fine but the output is "OK, hello". I want to get rid of this OK and just print a script.

Thanks for the answers, here are some useful links related to them

Forgive my non-applescript nomenclature - I hope this is useful to people like me looking at the issue.


Solution

  • display dialog returns a record with keys button returned and text returned. Actually there is third key gave up which appears only if the parameter giving up after is specified

    You can write

    on run prompt
        set theResponse to display dialog prompt default answer ""
        return text returned of theResponse
    end run
    

    or

    on run prompt
        set {text returned: textReturned} to display dialog prompt default answer ""
        return textReturned
    end run