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

    Use of set meta command

    Scheduled Pinned Locked Moved
    Gcode meta commands
    1
    1
    149
    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.
    • hlwerschnerundefined
      hlwerschner
      last edited by

      I can not count the places in my macros where I have to use code like

      if !exists(global.xyz)
        global xyz = some complex expression
      else
        set var.xyz = SAME complex expression
      

      This is caused by that HARD restriction that the "set" command EXPECTS the assigned variable to exist. I even may do a

      if !exists(var.xyz)
        var xyz = 0 ; or any fake value
      set var.xyz = to the really wanted expression value
      

      but I am not happy with this - for example the really set value type may not be numeric - but I know that this is an argument of esthetics.

      My sugestion: (a) add another command - perhaps name it "assign" - that is a "set" but automatically will do a create of that variable before if neccessary.
      Or (b) add a gcode like "Mxxx 0 / 1" which defines the behaviour of "set" on a global base.
      Both options will not block to use the old coding but the will help to write cleaner and more secure macros.

      1 Reply Last reply Reply Quote 1
      • First post
        Last post
      Unless otherwise noted, all forum content is licensed under CC-BY-SA