Skip to content

Basic Data Type Entities (INT, DOUBLE, STRING, BOOL)

LOT handles basic data types implicitly. While you don't explicitly declare variables with types like INT or STRING in LOT code itself (like you might in general-purpose programming languages), the language engine and associated components understand and operate on these fundamental types.

INT

  • Description: Represents whole numbers (integers).
  • Usage: Used in mathematical expressions, comparisons, and published as numeric payloads.
  • Example:
    PUBLISH TOPIC "counter" WITH 10
    IF GET TOPIC "level" >= 5 THEN ...
    ADD "offset" WITH (baseValue + 100)
    

DOUBLE

  • Description: Represents numbers with decimal points (floating-point numbers).
  • Usage: Used in mathematical expressions, comparisons, and published as numeric payloads.
  • Example:
    PUBLISH TOPIC "temperature" WITH 25.7
    IF GET TOPIC "voltage" < 3.3 THEN ...
    ADD "scaledValue" WITH (rawValue * 0.01)
    

STRING

  • Description: Represents sequences of text characters.
  • Usage: Used for status messages, identifiers, configuration values. String literals are enclosed in double quotes (").
  • Example:
    PUBLISH TOPIC "status" WITH "active"
    IF GET TOPIC "mode" == "MANUAL" THEN ...
    ADD "label" WITH "Sensor ID: " + GET TOPIC "sensor/id"
    

BOOL

  • Description: Represents boolean values true or false.
  • Usage: Primarily the result of comparison and logical operations, used in IF conditions. While you don't typically publish true/false directly, conditions evaluate to boolean.
  • Example:
    // Condition evaluates to BOOL
    IF GET TOPIC "temperature" > 30 THEN ...
    
    // Result of comparison is BOOL
    DEFINE MODEL CheckStatus WITH TOPIC "status/check"
        ADD "isHigh" WITH (GET TOPIC "value" > 100) // isHigh will be true or false
    

Type Conversion

LOT often performs automatic type conversion where appropriate, especially between numeric types and strings that represent numbers in mathematical or comparison operations.

// If topic "count_str" holds the string "5", LOT treats it as number 5 here
PUBLISH TOPIC "count_num" WITH (GET TOPIC "count_str" + 1)

Related Documentation