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

    Protect against empty params?

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    2
    3
    142
    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.
    • oozeBotundefined
      oozeBot
      last edited by oozeBot

      Is there a way to protect against a param that isn't sent into a file/macro? If not, can one be added? Or could it default to null?

      Example: When using {param.C} in the system file M9000.g, calling M9000 C"test" works, but just calling M9000 errors out.

      I'm hoping there is already a way to handle this that just isn't clearly documented. Thanks!

      dc42undefined 1 Reply Last reply Reply Quote 0
      • oozeBotundefined oozeBot marked this topic as a question
      • dc42undefined
        dc42 administrators @oozeBot
        last edited by

        @oozebot you can use the exists function at the start of the macro to check whether the parameter is present.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        oozeBotundefined 1 Reply Last reply Reply Quote 0
        • oozeBotundefined
          oozeBot @dc42
          last edited by

          @dc42 got it working - thanks! It didn't work when I tried but I was using {} around it.. and the documentation only showed that working for variables, so I moved on. For other's reference, the working call looks like:

          echo exists( param.C )
          
          1 Reply Last reply Reply Quote 2
          • oozeBotundefined oozeBot has marked this topic as solved
          • First post
            Last post
          Unless otherwise noted, all forum content is licensed under CC-BY-SA