BrightSign BrightScript 2 Reference Guide User Manual
Page 32

32
m.result=m.a+m.b
end function
If a function is not called from an AssociatiaveArray, then its “m” is set to an
AssocicateArray that is global to the module, and persists across calls.
Anonymous Functions
A function is anonymous if it does not have a name. It can be declared like this;
myfunc=function (a, b)
Return a+b
end function
print myfunc(1,2)
They can be used with AA literals like this:
q = {
starring : function(o, e)
str = e.GetBody()
print "Starring: " + str
toks = box(str).tokenize(",")
for each act in tok
actx = box(act).trim()
if actx <> "" then
print "Actor: [" + actx + "]"
o.Actors.Push(actx)
endif
next
return 0
end function
}
q.starring(myobj, myxml)