The following behavaiour has me really puzzled.
If I execute this script, and set a breakpoint at line 23 as indicated, the variables pane shows an unexpected view of the variable “theRecordList” if it is declared as a local variable.
If “theRecordList” is declared a local variable, then at the breakpoint, the variables pane shows the s_ID property in each record to be “0”, even though the script has changed the values. The values of s_ID have changed, because the new values are retrieved correctly in “theCheck1” variable - {10,11,12}
On the otherhand, if “theRecordList” is declared a global variable, then he variables pane shows the s_ID property in each record to be the latest value, i.e. 10,11,12.
What’s the reasoning behind the behaviour if the variable is local?
someHandler()
on someHandler()
local settingIDctr, theRecord, dummy, theCheck1
---global theRecordList
local theRecordList
set theRecordList to {}
set end of theRecordList to {s_ID:0, s_Name:"Name1", s_Value:"some Value1", s_enable:true}
set end of theRecordList to {s_ID:0, s_Name:"Name2", s_Value:"some Value2", s_enable:true}
set end of theRecordList to {s_ID:0, s_Name:"Name3", s_Value:"some Value3", s_enable:true}
set settingIDctr to 10
repeat with theRecord in theRecordList
set theRecord's s_ID to (get settingIDctr as integer)
set settingIDctr to settingIDctr + 1
end repeat
set theCheck1 to {}
repeat with theRecord in theRecordList
set the end of theCheck1 to ((get theRecord's s_ID) as integer)
end repeat
theCheck1 -- set a breakpoint here
end someHandler