Imported from the Apple Support Forums via the Wayback Machine 🔗
This is an important and useful feature of AppleScript. When referencing items in a list, positive numbers work from the beginning of the list while negative numbers work from the end.
For example, you can use 'word 1' to get the first word of a string, or 'paragraph -2' to get the penultimate paragraph.
0
Chachi·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi Spencer,
Adding to the info you've already gotten in this thread...
Try this:
set xx to "test string" set xx to text -2 through -1 of xx --sets xx to the text string "ng"
or this:
set xx to "test string" set xx to characters -2 through -1 of xx --sets xx to the list {"n", "g"}
depending on how you need the characters returned to you in your script.
Hope this helps...
0
Jacques Rioux·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hello.
-2 are the last two characters in the string.
set xx to text -2 thru -1 of xx
0
Spencer Lips1·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi thanx, that did the trick, it's all so easy as you see the answer.