Reusable DAS Script Modules and Execution Contracts
Design helper inputs, outputs and ownership around ExecHotkey and Exec.
A named hotkey can be a module
Prerequisite: events/reuse and custom objects. A helper hotkey does not need a physical key binding. It still executes in the DAS environment and shares globals. There is no documented function-parameter declaration or local-stack isolation in this model. Define a message contract: configuration in, result out, ready flag and error text.
Define the helper body
Create a hotkey named FE_CalcNotional with exactly the following body. Advanced Script · pure calculation using the caller-provided object. The caller must create all fields before invoking it.
Helper code
$feCalc.ready = 0;
$feCalc.result = 0;
$feCalc.error = "Invalid quantity or price";
if ($feCalc.quantity > 0) {
if ($feCalc.price > 0) {
$feCalc.result = $feCalc.quantity * $feCalc.price;
$feCalc.error = "";
$feCalc.ready = 1;
}
}
Define the caller
$feCalc = NewUserObj();
$feCalc.quantity = 40;
$feCalc.price = 8.25;
$feCalc.ready = 0;
$feCalc.result = 0;
$feCalc.error = "Not run";
ExecHotkey("FE_CalcNotional");
if ($feCalc.ready == 1) {
MsgBox($feCalc.result);
} else {
MsgBox($feCalc.error);
}
Why the contract matters
Expected result: 330. The helper clears old output before validation and writes ready last. The caller does not assume the helper succeeded just because control continued. These are script-composition conventions, not broker transactions. A timer that also writes $feCalc can corrupt the handoff; use one owner or separate records. Avoid recursive helper cycles. A dependency graph should end in small, auditable bodies.
Source text and execution are different assets
GetHotkeyScript obtains a source string. Saving that string creates a snapshot; later editor changes do not rewrite it. Exec executes the string you actually pass. Prefer fixed reviewed helper names over constructing code from untrusted text. Escaping quotes solves syntax nesting, not authorization or type validation. For a reusable release, record helper names and source revisions together, rather than distributing a caller alone.
Exercise and worked answer
Set quantity to zero after one successful call. Answer: the helper must return ready=0, result=0 and an explanatory error rather than leave 330. Add a second helper for display that only reads the result record. Its dependency contract must state that it never changes configuration or sends orders. Test a missing helper name separately in the practice build.