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

    Q: How to check the type of a variable?

    Scheduled Pinned Locked Moved
    Firmware wishlist
    2
    4
    202
    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.
    • AndMazundefined
      AndMaz
      last edited by AndMaz

      Is there a way to check the type of a variable? Something like typeof(global.fanSpeed) and result would be bool, int, float, string, DateTime, object or array

      If this is not possible atm, can you please add this feature? It will help a lot with params validation

      dc42undefined 1 Reply Last reply Reply Quote 1
      • dc42undefined
        dc42 administrators @AndMaz
        last edited by

        @AndMaz I'm sorry, we don't currently provide a way to check the type of a variable, other than to check if it is null. Can you provide more details about the use case?

        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

        AndMazundefined 1 Reply Last reply Reply Quote 0
        • AndMazundefined
          AndMaz @dc42
          last edited by

          @dc42 I would like to validate the input before doing any actual printing. For example, in M98 P"my-macro.g" S100 Y"123" the Y value is passed as a string instead of a int.

          dc42undefined 1 Reply Last reply Reply Quote 0
          • dc42undefined
            dc42 administrators @AndMaz
            last edited by

            @AndMaz I creates this github issue https://github.com/Duet3D/RepRapFirmware/issues/865.

            dc42 created this issue in Duet3D/RepRapFirmware

            open [FeatureRequest]: Add a means to check the type of a variable #865

            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

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