Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    [3.6.0-rc.2] error: Unexpected characters after expression

    Scheduled Pinned Locked Moved Solved
    Beta Firmware
    2
    3
    59
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • marvineerundefined
      marvineer
      last edited by

      Ones more 🙂

      I have the following 0:/macros/Lights/set.g to control two different lights at my machine:

      ; call this to set any light to a given value or call this to turn off all lights
      ; can be called with parameter D: String of the device (light) you want to control ("main", "head"), all if permitted
      ; can be called with parameter B: Power the given light is set to, 0 if permitted
      
      ; create var for power and check input for out of bound
      var power = 0
      if exists(param.B) && param.B >= 0 && param.B <= 1:
          set var.power = param.B
      
      ; set each device accordingly
      if !exists(param.D) || param.D == "main":
          M42 P0 S{var.power}
      
      if !exists(param.D) || param.D == "head":
          M42 P1 S{var.power}
      
      

      When executing thjs via M98 P"0:/macros/Lights/set.g", I get the following:
      Error: in file set.g line 8: Unexpected characters after expression

      With 3.5.4 this macro executed without any warning or error.

      Any idea on that?

      gloomyandyundefined 1 Reply Last reply Reply Quote 0
      • gloomyandyundefined
        gloomyandy @marvineer
        last edited by

        @marvineer Try removing the colon ":" at the end of each of the if statements. See: https://docs.duet3d.com/User_manual/Reference/Gcode_meta_commands#conditional-construct

        1 Reply Last reply Reply Quote 1
        • marvineerundefined
          marvineer
          last edited by

          oh wow, sometimes the obvious...
          Thanks!

          1 Reply Last reply Reply Quote 0
          • marvineerundefined marvineer marked this topic as a question
          • marvineerundefined marvineer has marked this topic as solved
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA