• 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: Running script from shortcuts v editor?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Running script from shortcuts v editor?


  • Subject: Re: Running script from shortcuts v editor?
  • From: "koenig.yvan" <email@hidden>
  • Date: Sun, 27 Jan 2013 18:59:13 +0100


Le 27/01/2013 à 18:35, Peter R Hawkes <email@hidden> a écrit :

The code;

tell application "Evernote"

set theNote to selection

set theNoteTitle to (title of item 1 of theNote) as string

display dialog theNoteTitle --1

set theX to offset of "[" in theNoteTitle

if theX is not 0 then

set theText to text ((offset of "[" in theNoteTitle) + 1) thru -1 of theNoteTitle

display dialog theText  --2

set theText to rstripString(theText, "]") of me

display dialog theText  --3

else

set theText to "1d"

end if

……. and on to do things to the Note!!

on rstripString(theText, trimString)
local theText, trimString, x
try
set x to count trimString
try
repeat while theText ends with trimString
set theText to characters 1 thru -(x + 1) of theText as text
end repeat
return theText
on error number -1700
return ""
end try
on error eMsg number eNum
error "Can't trimBoth: " & eMsg number eNum
end try
end rstripString

theNoteTitle is displayed in the dialog (all dialog just for debugging) at --1 as Test [6d]

at --2 it correctly becomes 6d]

the problem comes at --3 when if the script is run from keyboard shortcut (Fastscripts) theText is shown as 6=d but, if the script is run from the AppleScript Editor theText is correctly shown as 6d

Sorry for length of explanation but I fail to see why there is a difference based on how the script is run?


This edited one does the trick :



set theNoteTitle to "azerty [the title] zzzz"

display dialog theNoteTitle --1

set theX to offset of "[" in theNoteTitle

if theX is not 0 then


set theText to text (offset of "[" in theNoteTitle) thru -1 of theNoteTitle # EDITED


display dialog theText --2


set theText to rstripString(theText, "]") of me


display dialog theText --3


else


set theText to "1d"


end if

-- and on to do things to the Note!!

on rstripString(theText, trimString)
local theText, trimString, x
try
# EDITED
try
repeat until theText ends with trimString # EDITED
set theText to text 1 thru -2 of theText # EDITED
end repeat
return theText
on error number -1700
return ""
end try
on error eMsg number eNum
error "Can't trimBoth: " & eMsg number eNum
end try
end rstripString


Yvan KOENIG (VALLAURIS, France) dimanche 27 janvier 2013 18:59:07


 _______________________________________________
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

References: 
 >Running script from shortcuts v editor? (From: Peter R Hawkes <email@hidden>)

  • Prev by Date: Running script from shortcuts v editor?
  • Next by Date: Call PowerPoint 2011 VBA Subroutine From AppleScript [SOLUTION]
  • Previous by thread: Running script from shortcuts v editor?
  • Next by thread: Re: Running script from shortcuts v editor?
  • Index(es):
    • Date
    • Thread