Forum Discussion
RokuMarkn
11 years agoVisitor
Be aware that that are (somewhat confusingly) two different meanings of m. If you are in a function called through an AA, then m refers to that AA. For example:
On the other hand if you are NOT in such a function, them m refers the the "global" AA:
The first mechanism is how Brightscript implements object-oriented programming, and is something you should definitely use. The second mechanism (global variables) is evil and should be used with caution, if ever.
--Mark
aa = { func1: my_func1, data: 42 }
aa.func1(5) ' call through an AA
function my_func1(x as Integer)
' x is 5, m.data is 42
end function
On the other hand if you are NOT in such a function, them m refers the the "global" AA:
m.data = 43 ' sets the global AA
func2(5) ' not called through an AA
function func2(x as Integer)
' x is 5, m.data is 43
end function
The first mechanism is how Brightscript implements object-oriented programming, and is something you should definitely use. The second mechanism (global variables) is evil and should be used with caution, if ever.
--Mark