GUI Manual · Chapter 4
title: "Run Module" chapter: 4 source: "Doc/QMachineStudio UserManaul.pdf" images:
- run-module.png
- run-module-sequence.png
Run Module
Run Module is where the scripts that actually drive the machine live. It is organized into four building blocks — variables, functions, sequences, and steps.

Parts
Variable
Global variables that carry machine state: counters, flags, target coordinates.
int cycleCount = 0;
bool initOk = false;
double lastTargetX = 0.0;Variable names are unique across the project. Rename propagates automatically to every reference.
Functions
Reusable logic called from sequences — hardware checks, shared error handling, init routines.
bool MoveToLoadPos(void) {
Motor[X].MoveAbs(100.0, true);
Motor[Y].MoveAbs(50.0, true);
return Motor[X].CheckInPosition(100.0)
&& Motor[Y].CheckInPosition(50.0);
}Sequence
The machine's main state flow. During runtime, sequences run in order and only one step is active at any time.

Step
Sub-units inside a Sequence. NextStep("Name") transitions to the next step, and entry/exit times
are logged automatically.
Editing flow
- Declare globals in the Variable tab
- Write reusable logic in Functions
- Create the
MainSequence and describe each Step F6to save/build,F5to run and verify
Tips
- Keep sequences short. One step ≈ one state transition — keeps debugging clear.
- Move duplicated logic into Functions.
- Use meaningful names:
F12jumps to definition,Shift + F12finds references.