• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Simple Display Dialog confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Simple Display Dialog confusion


  • Subject: RE: Simple Display Dialog confusion
  • From: Rick Gordon <email@hidden>
  • Date: Thu, 17 Jul 2008 13:19:30 -0700

Re-sent with plain text.

-----

At 1:03 PM -0700 7/17/08, John Baltutis wrote:
> > Date: Thu, 17 Jul 2008 11:37:39 -0700
> > From: Rick Gordon <email@hidden>
> > Subject: RE: Simple Display Dialog confusion
> >
>> An HTML attachment was scrubbed...
> > URL:
> >http://lists.apple.com/mailman/private/applescript-users/attachments/20080717/9a64e3c2/attachment.html
>
>************
>Send plain text and this shouldn't happen. BTW, what was it you were trying to
>say?

-----

A couple things to consider here:

First, to get the button returned, you need the button returned from something, so create a variable to load what's returned from the dialog, that way you have more than one crack at extracting values.

But also, "Cancel" basically generates an error and stops the script, so yu're never even getting there if the user choose "Cancel." So nest the dialog in a try clause, and use the "on error" to process or recover. Or don't name the button "Cancel."

set prompt to "Enter Date to import (MM/DD/YYYY)"
set mydate to current date
set today to (month of mydate as integer) & "/" & day of mydate & "/" & year of mydate

try
	set dialogresult to (display dialog prompt default answer today as string ¬
		buttons {"Cancel", "OK"} default button 2)
on error  --Cancel generates error.
	return "woof"
end try

set today to text returned of dialogresult

if button returned of dialogresult is "OK" then
	beep 4
else
	beep 2
end if

------------------

On 7/17/08 at 2:11 PM -0400, Gary Thompson wrote in a message entitled
"Simple Display Dialog confusion":

>Hello,
>
>Can someone tell me how to get the 'button returned' from the display dialog?
>
>set prompt to "Enter Date to import (MM/DD/YYYY)"
>set mydate to current date
>set today to (month of mydate as integer) & "/" & day of mydate & "/" & year of mydate
>set today to text returned of (display dialog prompt default answer today as string buttons {"Cancel", "OK"} default button 2)
>
>This does not seem to work:
>if button returned is "Cancel" then
>	-- exit
>else
>	--do stuff
>end if
>
>Thanks, Gary


--

___________________________________________________

RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________

WWW:   http://www.shelterpub.com
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: UI scripting question
  • Next by Date: Re: UI scripting question
  • Previous by thread: Re: Simple Display Dialog confusion
  • Next by thread: Anyone here using source control?
  • Index(es):
    • Date
    • Thread