The Code Editor

Karl Falconer · Updated

The code editor is the text view of a rule. It uses BGL — DropStream’s rule language. You don’t need to use the code editor; the visual editor covers most rules. But for power users and for rules with advanced features, code is faster.

The BGL Code Editor showing a rule with syntax highlighting

Switching between Visual and Code

Use the Visual / Code tabs in the editor header. They show the same rule — switching back and forth is lossless as long as the visual editor can render every statement. If it can’t, the visual tab will fall back to the code view automatically.

What BGL looks like

BGL reads close to English. The example above:

rule "Set shipping method"
  when
    true
  then
    set order.shipping_carrier_name to "UPS"
    set order.shipping_warehouse_code to "UPS03"
    set order.shipping_carrier_service_level to "Ground"
  end
end

A rule has a name in quotes, a when block (the condition), a then block (the actions), and an end to close each.

For the full language, see the BGL language reference (coming soon).

Editor features

The code editor includes:

  • Syntax highlighting — keywords, strings, numbers, attribute paths, and operators are color-coded.
  • Autocomplete — type a few characters and the editor suggests keywords, attribute names, and snippets. Press Ctrl+Space to invoke completion manually.
  • Snippets — type the start of a common pattern (like set, when, for, route) and press Tab to expand a template. See Snippets Reference for the full list.
  • Folding — click the gutter arrows to collapse when, then, for, and accumulate blocks.
  • Auto-indent — pressing Enter indents to the right level for the block you’re inside.

When to drop into code

Most rules are easier to read and edit in the visual editor. Reach for the code editor when:

  • You’re comfortable with BGL and want to type fast.
  • The rule uses a feature the visual editor doesn’t render (regex captures, nested accumulate, certain custom expressions).
  • You want to copy a rule between accounts — the BGL text is portable.
  • You’re learning the language and want to see what the visual blocks compile to.

Validation on save

When you save, the editor parses your code. If there’s a syntax error, you’ll see a message and the rule won’t be saved until you fix it. Errors are usually obvious — a missing end, a typo in a keyword — and the message includes the line number.

Runtime errors (problems that only show up when the rule actually runs against real data) don’t surface here. Use the Test tab to catch those before activating the rule.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.