FennEdge Learn · Programming

DAS Trader Advanced Hotkey Script Course

Understand the code. Inspect the state. Verify the outcome. A detailed path through Advanced Script: language, data structures, order objects, event workflows and complete practice projects.

Plan about 1046 minutes including reading, worked examples, and each lesson exercise; actual time varies.

36Lessons≈1046Est. minutes—Sign in to save progress
04
Lesson 4 of 36 · About 22 min

DAS Script Input Prompts and Parameter Validation

Turn Input into an explicit input contract, not executable text.

A prompt is a boundary

Prerequisite: variables and conditions. A useful script accepts parameters without requiring edits to its body. Input returns a value supplied through a prompt; the guide shows both Input() and Input(Title, Message). It does not provide a complete cancellation or conversion contract. Separate collecting, validating and using the value. This lesson displays text only.

Start with an observable contract

Advanced Script · prompt and display, run manually. This accepts a nonempty label, not executable code. Empty-string handling is deliberately separate from the still-unverified Cancel contract.

The complete text-input example

$feInputReady = 0;
$feInputLabel = "";
$feInputLabel = Input("FE observation", "Enter an observation label");
if ($feInputLabel == "") {
    MsgBox("No label entered");
    return;
}
$feInputReady = 1;
MsgBox("Label: ", $feInputLabel);

Read the sequence

The ready flag becomes zero before opening the prompt. Therefore a prior successful run cannot authorize this run. The result is held separately from the flag. Only after validation does ready become one. Whitespace is not removed by this example: a string containing spaces can pass the empty-string check. Do not invent trim(), Number(), isNaN() or regular expressions from JavaScript. If your application requires a normalized ticker, define and verify that adapter separately.

Numbers, defaults and cancellation

A prompt returning "25" does not by itself establish a reliable numeric parser. Test 25, 25.5, 0, -1, spaces, letters and Cancel in your exact build before arithmetic. The documented two-argument signature does not establish a third default-value parameter. Keep a default in a separate configuration value; choose it only under a documented fallback rule. Never use Exec(Input()) for parameter entry: that changes the input contract from data to arbitrary DAS code.

Exercise and worked answer

Design a label prompt with an explicit fallback label "Untitled". Write the expected result for an empty string, a normal label and spaces. Answer: replace only the verified empty string with the fallback; preserve other text until normalization is specified. Keep ready zero when cancellation behavior is unknown. A downstream module must check ready and must not reuse last-run output.