Thanks for the suggestion. It helped me identify the problem and it is a little more involved - not sure what is broken where (is it AppleScript, ScriptDebugger, pilot error = me). Something is really wrong here - or I do not understand it.
use AppleScript version “2.5”
– use framework "Foundation"
use scripting additions
property x : "missing Value"
set x to p
set y to 4
set z to 5
set z to 6
– local a
set a to initialize()
set b to initialize()
tell a to doStuff(3)
tell b to doStuff(44)
set d to 2
Works as expected - Script Debugger shows properties and variables variables as expected.
If I uncomment “-- local a”
- Both object instances a and b appear as I step over them - looks good.
- When I step through doStuff for object instance a I do not see a and property x but do see local variable y
- The final result if I stop at “set d to 2” is that x in object a is set to “missing value”
If I then uncomment “-- use framework “Foundation””
- Both object instances a and b appear as I step over them - but object a is shown as <>.
- When I step through doStuff for object instance a I do not see any variables or properties
- The final result if I stop at “set d to 2” is a is shown as empty
Conclusion - do not use local when instancing objects.