exprv4:tutorials:what_is_expr



What is Expression?

Expression, or Expr for short, is the scripting language used by PlanetCNC software for calculations, automation logic, machine customization, user interface extensions, and integration tasks.

Expr lets you change and extend behavior without recompiling the application. This is useful because CNC machines and automation systems are often configured differently: different inputs, outputs, sensors, tools, workflows, safety rules, and external devices may need different logic.

Expr can be used like a powerful calculator, but it is also used as a scripting layer for PlanetCNC workflows. Expr scripts can be called from G-code, used to create custom dialogs and forms, and used as an alternative to G-code scripts for larger automation tasks.


What Expr Is Used For

Expr is used for tasks such as:

  • Calculating values and formulas.
  • Creating reusable variables and functions.
  • Making decisions with conditions.
  • Repeating work with loops.
  • Customizing machine behavior.
  • Creating custom dialogs and forms.
  • Running logic called from G-code.
  • Writing ATC, probing, and other complex workflow scripts.
  • Writing PLC-like automation logic.
  • Handling safety and process sequences.
  • Integrating external devices and controllers.

For example, Expr can calculate a value, check a condition, choose what should happen next, show a custom dialog, run probing logic, or execute a tool-change sequence.


What Expr Is Not

Expr is intentionally focused. It is not meant to replace every programming language or every part of the control system.

Expr is not:

  • A general-purpose system programming language.
  • A language for building standalone applications.
  • A replacement for firmware or real-time motion control.
  • A replacement for low-level machine safety design.

Expr is best used for customization, automation, integration, and runtime logic inside PlanetCNC.


How Expr Looks

Expr uses familiar syntax for numbers, variables, operators, conditions, loops, and functions.

a = 10;
b = 20;
 
result = a + b;
 
if(result > 25)
{
    'large';
}
else
{
    'small';
};

In this example:

  • `a` and `b` are variables.
  • `a + b` is an expression.
  • `if` chooses between two blocks.
  • The final result is either `'large'` or `'small'`.

How To Read These Tutorials

If you are new to Expr, read the tutorial pages in order. Each page introduces one small part of the language and builds on the previous page.

Next: First expression

exprv4/tutorials/what_is_expr.txt · Last modified: by 127.0.0.1

Page Tools