BrightSign BrightScript 3.0 Reference Manual User Manual

Page 51

Advertising
background image

46

Anonymous Functions
A function without a name declaration is considered anonymous.

Example: The following is a simple anonymous function declaration.
myfunc=function (a, b)

Return a+b

end function

print myfunc(1,2)

Example: Anonymous functions can also be used with associative-array literals.
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
end for
return 0
end function
}

Advertising