DAS Script Dynamic Variables: GetVar, SetVar and DelVar
Use GetVar, SetVar and DelVar with ownership and reset rules.
Why address a variable by name?
Prerequisite: global-variable scope. A fixed assignment is simplest for one configuration. Name-based access becomes useful when a module selects among named configuration values. GetVar reads a global variable using a string; SetVar writes it; DelVar removes named variables. This is indirection, not local scope, persistence or an account namespace.
API contract and naming
The guide lists GetVar(varname), SetVar(varname,value) and DelVar(Varname1, Varname2,…). It does not illustrate whether every build accepts the $ prefix inside the string. Use one naming convention, then verify a SetVar/GetVar round trip and inspect the Hotkey Script Variable window. Do not try both variants against production state: they could address different variables. The example uses a dedicated name without a $ in the string and is a naming-convention probe.
Write, read and remove your own value
$feRegistryName = "FE_Practice_ConfigRevision";
SetVar($feRegistryName, 3);
$feRegistryValue = GetVar($feRegistryName);
MsgBox("Revision: ", $feRegistryValue);
DelVar($feRegistryName);
Ownership is part of the schema
Expected round-trip value: 3. The last line deletes the dynamically addressed value, not $feRegistryName or $feRegistryValue. Deletion does not establish what a later missing read returns. Use a written register of owner, type, initialization, consumers and reset event. With case-insensitive globals, FE_State and fe_state are not two independent names. For multiple stocks, prefer a collection object to a large ad hoc family of global names.
Reset, delete and persist are different
Reset assigns an explicit state such as ready=0. Delete removes the name. Neither operation writes durable storage. A bootstrap hotkey should create the state expected by every consumer; a stop hotkey should disable callbacks before deleting their dependencies. Avoid deleting a variable while a timer is still reading it. Do not rely on wildcards: the source lists named arguments for DelVar, not a namespace-wide deletion contract.
Exercise and worked answer
Two helpers both write a value called ready. Propose a repair. Answer: give each helper a unique owner prefix, document which caller initializes it, and publish the output only after success. If a shared configuration is intentional, centralize writes in one helper. Test resetting while callbacks are disabled, then restarting from initialization.