• 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
Rép: script differences ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: script differences ?


  • Subject: Rép: script differences ?
  • From: Yvan KOENIG <email@hidden>
  • Date: Sun, 11 Oct 2015 15:06:45 +0200

Le 2015/10/11 à 14:15, Jean-Christophe Helary <email@hidden> a écrit :

Here is a script that I wrote myself, probably after checking a few things on the web:


activate application "Reminders"

tell application "Reminders"
set reminder_contents to text returned of (display dialog "Reminder:" default answer "")
make new reminder with properties {name:reminder_contents}
end tell


And here is another one that I found on the web and that does pretty much the same thing:


tell application "System Events"
display dialog "Create a new reminder" default answer "" cancel button "Cancel" giving up after 20 with icon path to resource "Reminders.icns" in bundle (path to application "Reminders")
set reminTitle to text returned of result
tell application "Reminders"
set newremin to make new reminder
set name of newremin to reminTitle
end tell
end tell


I'd like to know what is technically different between the two approaches. Is the second one "better" ? If yes, why ? What is there to learn from the approach adopted in the second one ? Is there anything wrong with the first approach ?

Thank you in advance for your insights.

Jean-Christophe 
_

I would not use such syntax.
#1 I would move the instruction triggering display dialog out of the tell application block because "display dialog" is not a "Reminders" command.

set reminder_contents to text returned of (display dialog "Reminder:" default answer "")

tell application "Reminders"
activate
make new reminder with properties {name:reminder_contents}
end tell

#2 I don't see any reason to speak to System Events.

I would code :

display dialog "Create a new reminder" default answer "" buttons {"Cancel", "Create"} default button 2 cancel button 1 giving up after 20 with icon path to resource "Reminders.icns" in bundle (path to application "Reminders")
set reminTitle to text returned of result
tell application "Reminders"
make new reminder with properties {name:reminTitle}
end tell


Yvan KOENIG running El Capitan 10.11.0 in French (VALLAURIS, France) dimanche 11 octobre 2015 15:03:09








 _______________________________________________
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

  • Follow-Ups:
    • Re: script differences ?
      • From: Shane Stanley <email@hidden>
    • Re: Rép: script differences ?
      • From: Steve Mills <email@hidden>
  • Prev by Date: Re: script differences ?
  • Next by Date: Re: script differences ?
  • Previous by thread: Re: script differences ?
  • Next by thread: Re: Rép: script differences ?
  • Index(es):
    • Date
    • Thread