Skip to content

Instantly share code, notes, and snippets.

@midore
Created February 10, 2009 09:39
Show Gist options
  • Save midore/61328 to your computer and use it in GitHub Desktop.
Save midore/61328 to your computer and use it in GitHub Desktop.
dialog-lib, call.applescript:<http://gist.github.com/61329>
script scp_dialog
on cased given mytitle:t, message:m, button:b, myicon:i, givefter:g, type:type, ans:a, mylist:l
if type is "default" then default(t, m, b)
if type is "default_withicon" then default_withicon(t, m, b, i)
if type is "giveafter" then giveafter(t, m, b, i, g)
if type is "inputtext" then inputtext(t, m, b, a)
if type is "chooselist" then chooselist(t, m, l)
end cased
on default(t, m, b)
tell application "Finder" to set a to display dialog m buttons b default button 1 with title t
return item 1 of text of a
end default
on default_withicon(t, m, b, i)
tell application "Finder" to set a to display dialog m buttons b default button 1 with title t with icon i
return item 1 of text of a
end default_withicon
on giveafter(t, m, b, i, g)
tell application "Finder"
display dialog m buttons b default button 1 with title t with icon i giving up after g
set res to result
end tell
set a to item 1 of text of res
return gave up of res
end giveafter
on inputtext(t, m, b, a)
tell application "Finder" to set a to display dialog m default answer a buttons b default button 1 with title t
return item 1 of text of a
end inputtext
on chooselist(t, m, l)
tell application "Finder" to set choice to choose from list l with prompt m with title t
if choice is false then
error number -128
else
return choice as text
end if
end chooselist
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment