I’ve been encountering odd behavior with list variables. This is a case of seeming mismatch between SD (7.0.12) variable pane and Apple Events. AS returns the same event log. I restarted and got the same behavior. (Sorry that I can’t remember how to post code in the forum and the FAQ link now references rules of behavior.)
use AppleScript version “2.4” – Yosemite (10.10) or later
on run
local theList
set theList to {1, 2, 3}
log theList -- event = (*1, 2, 3*) SD var pane = {1, 2, 3}
log test(theList) -- event = (*4*) SD var pane = {1, 2, 3}
log theList -- (*4, 2, 3*) SD var pane = {1, 2, 3}
end run
on test(l)
set item 1 of l to 4
end test
I get similar behavior with setting list item in same handler.
on run
local theList, l
set theList to {1, 2, 3}
set l to theList
log theList -- event = (*1, 2, 3*) SD var pane = {1, 2, 3}
log l -- (*1, 2, 3*) SD var pane = {1, 2, 3}
set item 1 of theList to 4
log theList -- (*4, 2, 3*) SD var pane = {4, 2, 3}
log l -- (*4, 2, 3*) SD var pane = {1, 2, 3}
end run