I have never seen in any documents that Lingo allows properties to be added to an already existing instance.
For example:
— parent script "testScript"
on new( me )
return me
end new
— type in the message window
obj = script( "testScript" ).new()
obj[ #speed ] = 200
put obj.speed — 200
When I decided to study more carefully this functionality, I found that getProp() and setProp() bring different results compared to getAprop() and setAprop(). This becomes evident when the object, with properties created/modified by us, is a script instance inheriting another script. For example: There are three parent scripts (“A”, “B”, “C”). “C” inherits “B” and “B” inherits “A”:
— parent script "C"
property ancestor
on new( me )
ancestor = script( "B" ).rawNew()
callAncestor( #new, me )
return me
end new
— parent script "B"
property ancestor
on new( me )
ancestor = script( "A" ).rawNew()
callAncestor( #new, me )
return me
end new
— parent script "A"
on new( me )
return me
end new
If we write in the message window
obj = script( "C" ).new()
obj.setProp( #speed, 100 )
obj.setAprop( #speed, 200 )
put obj.getProp( #speed ) — 100
put obj.getAProp( #speed ) — 200
If we look at “obj” in the object inspector, we will notice that:
setProp() creates a property in the base script
setAprop() creates a property in the last successor ( child )
getProp() gets the value of the base script
getАProp() gets the value of the last successor ( child )