I experimented with this a bit and it seems I might not correctly understand what “it” is.
To be more specific about what Shane said the “it” can not appear by itself on the left side of the “to” but a part of the “it” can be referenced on the left side of the “to.” What fails is referencing “it” directly.
This works: set item 2 of it to (item 2 of it) + 1
This won’t even compile: set it to (item 2 of it) + 1
The part that is interesting is:
Example 1
set abc to {1, 2, 3, 4}
tell item 2 of abc
set B to a reference to it
set B to B + 1
end tell
(B as string) & " ——— " & abc as string
Returns: 3 ——— 1234
So a reference to “it” can be increment while “set it to it + 1” can not even be compiled.
In example 1 B references it.
When I add 1 to what B references I get 3 as the first part of the output shows.
In the second part of the output when I display the value of ABC, I can see item 2 of ABC, which B references, is 2.
When I run this:
Example 2
set abc to {1, 2, 3, 4}
tell abc
set B to a reference to it
set item 2 of B to (item 2 of B) + 1
end tell
abc
{1, 3, 3, 4} is returned showing item 2 of the referenced B changes from 2 to 3.
I expected the “a reference to” in example 1 to have to have changed the value in the ABC string and returned {1, 3, 3, 4}. But this didn’t happen. It’s like it referenced something other then item 2, something other then ABC string or both. My question is does “it” return a copy of the targeted object, instead of the actual referenced value in the targeted object?