Forum Discussion
kbenson
15 years agoVisitor
"Hexamon" wrote:
Excellent idea! Here's a bit more generalized version for creating pseudo-globals for something like global config options and don't want to turn the entire app into a pseudo-object (which is a good idea but geeks be lazy):
Function constructConfig()
m["config"] = createObject("roAssociativeArray")
End Function
Function getConfigValue(key as String) as Dynamic
config = m["config"]
return config[key]
End Function
Function setConfigValue(key as String, value as Dynamic)
config = m["config"]
config[key] = value
End Function
Yeah, we were planning on doing something for the RokuDev library, but never got around to it.
Have you tested that? I think I discovered that the global object was actually unique to each function (but it's been a while since I tested and I don't remember). Less like a global mechanism and more like a way to implement Singletons. If that's the case, getConfigValue and setConfigValue are working with different "m" objects, but you can still do it by creating a combined get/set function.