Hi all there,
I'm a complete novice in the area and I'm just learning from Hanaan Rosenthal, Hamish Sanderson "Learn AppleScript. A comprehensive guide, 3rd edition (2010)".
I came across this place in a section about constructing references of Part 2.Understanding how application scripting works. More on constructing references. The authors explain what relative references are (the subject about identifying elements), and then in the next section devoted to identifying a range of elements they write:
A third option is to use short references to the start and end elements themselves. For example,
tell application "TextEdit"
words 2 thru 4 of text of document 1
end tell
is really just shorthand for this:
tell application "TextEdit"
words (word 2) thru (word 4) of text of document 1
end tell
The start and end points are relative references, word 3 and word 6, that will be expanded using the reference to the container object, text of document 1 of application "TextEdit", as the base reference
I don't understand this passage. Related references define elements before or after another element. My questions:
1. How do we see that in this case word 3 and word 6 specifically are relative references if the script clearly states that word 2 through word 4 are the limiting points? Where word 5 got lost?
2. If indeed they are what's the author's point behind him claiming that "A third option is to use short references to the start and end elements themselves"? Why he calls it "references"? I don't get what is exactly being referred to and why these references are "short"? What is the difference between the command "words 2 thru 4 of text of document 1" and "words (word 2) thru (word 4) of text of document 1"?
Further on he continues:
In most applications, this isn’t a particularly useful way to write references, but some applications allow you to use different classes of elements for the start and end points. For instance, the following script obtains several words from a text frame in Adobe Illustrator:
tell application id "com.adobe.illustrator"
contents of words 2 thru 4 of text frame 1 of document 1
end tell
3. I don't get where these "different classes of elements for start and end points" in this example are?! I see just the class "words" being used. What are the "other classes"?
If some skillful user will grant me a part of his knowledge helping me to grasp this I would be very happy indeed.
I'm a complete novice in the area and I'm just learning from Hanaan Rosenthal, Hamish Sanderson "Learn AppleScript. A comprehensive guide, 3rd edition (2010)".
I came across this place in a section about constructing references of Part 2.Understanding how application scripting works. More on constructing references. The authors explain what relative references are (the subject about identifying elements), and then in the next section devoted to identifying a range of elements they write:
A third option is to use short references to the start and end elements themselves. For example,
tell application "TextEdit"
words 2 thru 4 of text of document 1
end tell
is really just shorthand for this:
tell application "TextEdit"
words (word 2) thru (word 4) of text of document 1
end tell
The start and end points are relative references, word 3 and word 6, that will be expanded using the reference to the container object, text of document 1 of application "TextEdit", as the base reference
I don't understand this passage. Related references define elements before or after another element. My questions:
1. How do we see that in this case word 3 and word 6 specifically are relative references if the script clearly states that word 2 through word 4 are the limiting points? Where word 5 got lost?
2. If indeed they are what's the author's point behind him claiming that "A third option is to use short references to the start and end elements themselves"? Why he calls it "references"? I don't get what is exactly being referred to and why these references are "short"? What is the difference between the command "words 2 thru 4 of text of document 1" and "words (word 2) thru (word 4) of text of document 1"?
Further on he continues:
In most applications, this isn’t a particularly useful way to write references, but some applications allow you to use different classes of elements for the start and end points. For instance, the following script obtains several words from a text frame in Adobe Illustrator:
tell application id "com.adobe.illustrator"
contents of words 2 thru 4 of text frame 1 of document 1
end tell
3. I don't get where these "different classes of elements for start and end points" in this example are?! I see just the class "words" being used. What are the "other classes"?
If some skillful user will grant me a part of his knowledge helping me to grasp this I would be very happy indeed.
Last edited: