Globals in Modular Stack Framework

Sannyasin Brahmanathaswami brahma at hindu.org
Mon Sep 2 10:24:42 EDT 2019


"setters" and "getters"

Hmm. I actually use that on a different module

actually, after talking with Andre.. .
what I am trying to do is create "caches" where a process does not need to run, say, every time you hit a card.

so he says "don't use config" …

sCacheA. # is a better name

Once you set up the "setter" and "getter" in the "engine" …
it's almost the same amt of code in the modular stack…

I'll try it…custom props don't work, because, during development, they are saved… which is not what  you want for "caches"

BR


Mark wrote

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
.


More information about the use-livecode mailing list