Skip to contentSkip to Content

Control flow

HDC always executes top to bottom, every time. There are no operators, no conditions on data, and the only repetition is LOOP. This page collects what little control flow the language has — and, just as importantly, what it deliberately leaves out.

Operators

HDC has no operators — no math (+, -, *, /), no comparisons (==, <, >), and no boolean logic (AND / OR / NOT). There’s nothing in the language that produces a new value from existing ones; every instruction just does something (type text, press a key, wait) and moves to the next line.

If you find yourself wanting to compute something, that computation needs to happen before the script is written, not while it runs.

Conditions

There’s no if / else, no switch, and no branching based on a condition. The closest things HDC has to conditional behavior are both tied to the physical Upload button rather than to data:

  • WAIT_FOR_BUTTON_PRESS — pauses the whole script until the button is physically pressed, then continues.
  • BUTTON_DEF … END_BUTTON — defines a block that runs whenever the button is pressed during execution, then returns to wherever the main script was interrupted.

Both are covered in full under System & device commands.

Loops

LOOP repeats a block of commands. Close it with END_LOOP:

loop.hdc
LOOP STRING . DELAY 500 END_LOOP

Written bare, or as LOOP TRUE, the block repeats forever — this is the form that works reliably today.

A counted loop (LOOP 5 … END_LOOP) is recognized by the compiler but isn’t fully supported by the current firmware yet. For now, treat LOOP as infinite-only, and reach for a function if you need a block repeated a fixed number of times — call it that many times in a row.

Last updated on