Skip to content

Gate, Signal, and Inventory Queries

These queries read the state of a gate, a signal, or an inventory location. Each names its object in quotes.

QueryWhat it returns
Gate("X").IsOpen1 if the gate is open, 0 if closed.
Signal("X").Active1 if the signal is currently on, 0 if off.
Inventory("X").Qty("Item")The quantity of a named item held at an inventory location.
Inventory("X").OnOrder("Item")The quantity of that item already on order and still to arrive.
Inventory("X").Value("Item")The value of the stock held: quantity times unit cost.

The three inventory queries take two names: the first is the inventory location, the second is the item held there.

Each line below is a complete piece of action logic, with a // note saying what it does.

The gate and the signal:

// Send work down the main path only while the inbound gate is open
IF Gate("Inbound").IsOpen = 1 THEN ROUTE 1 ELSE ROUTE 2 ENDIF
// Hold the entity here until the Go signal is turned on
WAIT UNTIL Signal("Go").Active

The inventory:

// Raise a reorder flag when the store runs low on widgets
IF Inventory("Store").Qty("Widget") < 20 THEN SET a_Reorder TO 1 ENDIF
// Stock already ordered and still in transit
SET a_Incoming TO Inventory("Store").OnOrder("Widget")
// Value tied up in widgets at this location
SET v_TiedUp TO Inventory("Store").Value("Widget")

Qty and OnOrder together give the inventory position, which is what a reorder decision should be made against. Counting stock on hand alone reorders the same item again and again while the first order is still on its way:

// Stock on hand plus stock on order, then reorder against that figure
SET a_Position TO Inventory("Store").Qty("Widget") + Inventory("Store").OnOrder("Widget")
IF a_Position < 20 THEN REQUEST 100 "Widget" FROM "Supplier" ENDIF

An item’s automatic replenishment policy already makes this comparison for you. Reach for these queries when you want to make the decision yourself, or to report on it.