I want to make a display box that has a text box that the user can enter a number into that will later be assigned to a variable. How would I do this?
Answer
Open AppleScript Editor, enter the following and save as script:
tell application "Terminal"
repeat while true
set input to display dialog "Enter a number:" default answer ""
if button returned of input is equal to "OK" then
try
return (text returned of input) as number
end try
end if
end repeat
end tell
(we need to tell application
, because otherwise osascript
doesn't allow user interaction)
Then run like this:
$ osascript path/to/script.scpt
Output of the program is the number the user entered.
Store in bash
variable like this:
$ foo=$( osascript path/to/script.scpt )
$ echo $foo
42
No comments:
Post a Comment