Banging my head, tried many suggestion on Google, no example is working for my. Running Mavericks, AppleScript 2.3.1
Giving the following example:
set s to "Today is my birthday" as text
log text 1 thru ((offset of "my" in s) - 1) of s
I get an error, “Cant get “my” in S, Access Access not allowed.”
Thank you, this is driving me crazy
Chris
Hi,
the code lines are without much doubt within an application tell block.
Either put the lines containing Scripting Addition terminology out of the tell block or write
tell application "Finder"
set s to "Today is my birthday"
tell current application to log text 1 thru ((offset of "my" in s) - 1) of s
end tell
See Scripting Addition Security in AppleScript Release Notes: 10.6 Changes
Hello
I just copied your two instructions and pasted them in AppleScript Editor.
The resulting Events log is :
tell current application
offset of “my” in “Today is my birthday”
→ 10
(*Today is *)
end tell
Are you sure that there is no invisible character (ID from 0 thru 31) between the m and the y in the long string ?
This kind of character is often dropped by the messages parsers.
A good test would be to do exactly what I did :
copy from the posted message and paste in the Editor.
I just see StefanK’s answer.
I must apologize but when I encapsulate in a tell Finder block, I get :
tell application “Finder”
offset of “my” in “Today is my birthday”
→ error number -10004
end tell
tell current application
offset of “my” in “Today is my birthday”
→ 10
end tell
tell application “Finder”
(*Today is *)
end tell
There is just the classical non-fatal error but the offset is correctly got.
Yvan KOENIG (VALLAURIS, France) jeudi 24 avril 2014 21:15:34