Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
include variables
#5
I don't recommend def. def constants will be global anyway. If you change def's value, you may have problems, because if other macros are already compiled with old value, they probably will not be updated.

Solution1
Use global structure:
Code:
Copy      Help
Code in entry macro:
type REGKEYS str'key1 str'key2 etc
REGKEYS+ _rk
_rk.key1="..."
_rk.key2="..."
etc

Here structure _rk is global variable (member strings will exist all time), but it is single name in global namespace.


Solution2
Create local structure in entry macro and pass pointer to it to called macros.

But if it is too complicated (eg, thread uses many functions, callback functions) then use Solution3.
Create local structure in entry macro and store pointer to it into thread-local variable. I'll show how to access it in all functions of that thread. This method is used in Dialog Editor.
Code:
Copy      Help
Code in entry macro:
type REGKEYS str'key1 str'key2 etc
REGKEYS rk
rk.key1="..."
rk.key2="..."
etc
tls0=&rk  ;;tls0 - 9 are thread-local ("sub-global") int variables
______________
Code in function that is directly or indirectly called from entry macro:
REGKEYS& rk=tls0
now use rk:
out rk.key1

Here structure rk is local variable (member strings are released when macro ends). Only one extra statement in each function where it will be used.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)