X-300 Script Simulator unofficial

Language reference

A summary in this site's own words. The official source is Appendix G, "BASIC Scripts", of the X-300 users manual (version 1.8). Each entry is marked:

Layout of a script

Statements

Statement What it does
LET var = value Store a value. The right side is one value, or two values with one operator.
IF value op value THEN … ELSE … END IF Run a block if the condition holds. THEN ends the line (the manual marks it optional, and the simulator warns if it's missing); one ELSE at most, on its own line; END IF is required.
DO … LOOP Repeat forever.
DO WHILE value op value … LOOP Repeat while the condition holds. With no condition it repeats forever, like DO.
FOR var = value TO value … NEXT var Count var up by 1 from the first value to the second, inclusive. (No STEP is documented.)
CALL name / SUB name … END SUB Run a subroutine and come back. Names are case-sensitive, up to 20 characters.
LOG Write a log entry, if logging is turned on in the unit's setup.
EMAIL Send the general email. EMAIL relay1 / EMAIL temp1 / EMAIL input1 send that item's message.
END Stop the main program.

PRINT only works in the vendor's PC syntax checker, not on the unit, so the simulator rejects it. There is no GOTO, AND, OR or NOT; use nested IFs and flag variables.

Conditions

IF, DO WHILE: one value on the left, a comparison, then a value or a one-operator sum on the right. if c <= b - h then is fine; if c + 1 > b then is not (put c + 1 in a variable first). (Documented)

Comparisons: =, <>, <, >, <=, >=.

Arithmetic

One operation per line. (The manual's examples only ever do one; the vendor's newer 400 series documents this rule explicitly.)

Operator Status
+, - Documented
% (remainder) Observed on real X-300s; documented for the 400 series
*, / Documented for the 400 series only. The simulator runs them but warns.

Negative numbers are written with no space: -3.

Variables

Name Read Write Notes
a … j yes yes Your ten variables. Numbers with decimals.
relay1 … relay3 0 or 1 0 off, 1 on, 2 pulse, 5 toggle A pulse turns the relay on for the pulse time set on the relay setup page, then off. The simulator uses 1 second.
rmt_relay1 … rmt_relay3 no yes Controls a relay on another unit, set up on the relay page. Can't be read back.
temp1 … temp8 yes no Temperature (or humidity, for a humidity sensor) in the unit's chosen units.
extvar0 … extvar4 yes yes External variables: also settable from the control page or over HTTP.
t0 … t5 yes yes Timers: count down by 1 every 0.1 s, stop at 0. Set them to 0 or a positive whole number.
time yes no Seconds since midnight. Compare with hh:mm:ss.
date yes no Days since 1 January 1970. Compare with mm/dd/yyyy.
ed1 … ed5, et1 … et5 yes yes Event date (days) and time (seconds) pairs. Adding past midnight to an et rolls its ed forward a day.

The manual isn't consistent about how many external variables there are: different pages show different ranges, one going up to extvar5. The unit's status page lists extvar0 to extvar4, so the simulator provides five.

Values you can write

From outside the script

Limits

Limit Value
Script size 1,900 bytes, counting line endings as 2 bytes
Nesting of IF/DO/FOR 5 deep (the simulator warns past 5; see below)
User variables 10 (a–j)
Timers 6
Subroutine name 20 characters

On nesting, the manual says IF, FOR and DO can each be nested five times, without saying whether a mix of them counts together. The simulator counts them together and warns, rather than refusing, past five. Staying within five in total is safe either way.