Globals in Modular Stack Framework

Mark Wieder ahsoftware at sonic.net
Sun Sep 1 12:57:47 EDT 2019


On 9/1/19 7:48 AM, Sannyasin Brahmanathaswami via use-livecode wrote:

> There are two ways to go with this:
> 
> 1) keep adding "keys" to the BIG global sConfigA
> OR
> 2) we could keep the custom properties of Stack Engine (which is always open)
> 
> Does anyone have experience and has come to "best practices" for this architecture? And why?

One way I deal with this situation is with getter and setter functions: 
It's a step away from global variables and you have more control and 
flexibility.

# in the main "engine" stack (move sConfigA here)
local sConfigA

function configArray pKey
   if pKey is empty then
     return sConfigA # return the whole array if needed
   else
     return sConfigA[pKey] # return just the requested value
   end if
end configArray

command setConfigTo pKey, pValue
   put pValue into sConfigA[pKey]
end setConfigTo

# in the "modular" stacks you can then
setConfigTo tKey, tValue

put configArray() into tRetrievalArray
put configArray(tKey) into tValue

-- 
  Mark Wieder
  ahsoftware at gmail.com




More information about the use-livecode mailing list