Re(5): Changing current date format
Re(5): Changing current date format
- Subject: Re(5): Changing current date format
- From: JF <email@hidden>
- Date: Mon, 20 Jan 2014 14:17:42 +0000
I have never noticed AppleScript being so user friendly.
Mon, 20 Jan 2014 14:13:49 +0000, JF wrote:
>You are right Yvan. I ran the script in AppleScript editor and the Event
>Log History reported the error, then AppleScript kindly corrected it,
>put in its own tell/end tell:
>
>snip
>
>...do shell script "date +'%d %B %Y'"
> --> error number -10004
>end tell
>tell current application
> do shell script "date +'%d %B %Y'"
> --> "20 January 2014"
>end tell
>tell application "Mailsmith"
> set subject of message window 1 to "Invoice dated 20 January 2014"
>
>end snip
>
>Mon, 20 Jan 2014 11:52:14 +0100, koenig.yvan wrote:
>
>>
>>Le 20/01/2014 à 11:02, JF <email@hidden> a écrit :
>>
>>> Thx for letting me know that I should not call standard additions
>>within application tell blocks.
>>>
>>> Just that the do shell script in the subject line works - quite by
>>accident it seems
>>>
>>> Mon, 20 Jan 2014 09:52:51 +1100, Shane Stanley wrote:
>>>
>>>> On 20 Jan 2014, at 5:16 AM, JF <email@hidden> wrote:
>>>>
>>>>> These ones worked best for me:
>>>>> set subject of foo to "Invoice dated " & (do shell script "date +%d%b%Y")
>>>>
>>>> The use of "set subject of foo to" suggests this is inside an
>>>> application tell block, which would mean you are calling the Standard
>>>> Additions command "do shell script" within it. That's not really a good
>>>> idea: with a couple of exceptions, you should keep you scripting
>>>> addition calls outside application tell blocks.
>>>>
>>>> --
>>>> Shane Stanley <email@hidden>
>>
>>Triggering an OSAX's function in a tell block generates a non fatal error.
>>
>>Example :
>>
>>tell application "Finder"
>> do shell script "date +%F"
>>end tell
>>
>>The log report is dirty :
>>
>>tell application "Finder"
>> do shell script "date +%F"
>> --> error number -1708
>> «event ascrgdut»
>> --> error number -1708
>> do shell script "date +%F"
>> --> error number -10004
>>end tell
>>tell current application
>> do shell script "date +%F"
>> --> "2014-01-20"
>>end tell
>>
>>If we really need to leave the offending instruction in the tell block
>>we may code :
>>
>>tell application "Finder"
>> tell me to do shell script "date +%F"
>>end tell
>>
>>and the log report will be the clean :
>>
>>tell current application
>> do shell script "date +%F"
>> --> "2014-01-20"
>>end tell
>>
>>Here is an other example :
>>
>>tell application "System Preferences"
>> set switchTo_loc to localized string "Switch to Space 1" from table ¬
>> "DefaultShortcutsTable" in bundle file ((path to system folder as
>>text) & "Library:PreferencePanes:Keyboard.prefPane:")
>>end tell
>>
>>The log is :
>>
>>tell application "System Preferences"
>> path to system folder as text
>> --> error number -1708
>> «event ascrgdut»
>> --> error number -1708
>> path to system folder as text
>> --> "Macintosh HD:System:"
>> localized string "Switch to Space 1" from table "DefaultShortcutsTable"
>>in bundle file "Macintosh HD:System:L
>>ibrary:PreferencePanes:Keyboard.prefPane:"
>> --> "Passer au Bureau 1"
>>end tell
>>
>>In fact the culprit is not localized string, it's path to.
>>
>>Run this cleaned code :
>>
>>(path to system folder as text)
>>
>>tell application "System Preferences"
>> set switchTo_loc to localized string "Switch to Space 1" from table ¬
>> "DefaultShortcutsTable" in bundle file (result &
>>"Library:PreferencePanes:Keyboard.prefPane:")
>>end tell
>>
>>This time the log in clean :
>>
>>tell current application
>> path to system folder as text
>> --> "Macintosh HD:System:"
>>end tell
>>tell application "System Preferences"
>> localized string "Switch to Space 1" from table "DefaultShortcutsTable"
>>in bundle file "Macintosh HD:System:L
>>ibrary:PreferencePanes:Keyboard.prefPane:"
>> --> "Passer au Bureau 1"
>>end tell
>>
>>No need to tell me that I was able to use :
>>path to library folder from system domain
>>--> alias "Macintosh HD:System:Library:"
>>or
>>path to "sprf"
>>--> alias "Macintosh HD:System:Library:PreferencePanes:"
>>
>>I'm aware of that ;-)
>>
>>Yvan KOENIG (VALLAURIS, France) lundi 20 janvier 2014 11:32:16
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>>Do not post admin requests to the list. They will be ignored.
>>AppleScript-Users mailing list (email@hidden)
>>Help/Unsubscribe/Update your Subscription:
>>@fmail.co.uk
>>Archives: http://lists.apple.com/archives/applescript-users
>>
>>This email sent to email@hidden
>
>
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>AppleScript-Users mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>@fmail.co.uk
>Archives: http://lists.apple.com/archives/applescript-users
>
>This email sent to email@hidden
_______________________________________________
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