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

    Echo command syntax

    Scheduled Pinned Locked Moved
    DSF Development
    3
    6
    190
    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.
    • Gamefanatic3Dundefined
      Gamefanatic3D
      last edited by Gamefanatic3D

      I was working with the echo syntax to incorporate the ">" & ">>" capabilities and was using the persistentGlobal.g file identified in the "GCode Meta Commands. However, when executing the file I receive the error:

      Error: in file macro line 6 column 7: meta command: expected a string expression
      

      fb2cb863-0808-44c7-9938-a306ee85ca57-image.png

      file: _TestVar1

      M98 P"/sys/scripts/persistentGlobal.g" V"testVar" X"one"
      

      After some back-and-forth, I found the root cause to be that the example had a space the ">" Removing the space resolved the problem. I only noticed this after looking at the earlier examples in the documentation which did not have the additional space where the filename was being provided.

      Old code:

      var id = param.V                    ; name of the global variable
      var value = param.X                 ; value to save
      var filepath = "globals/"^{var.id}  ; internal file path where the global variable is saved
      
      ; Save the global variable as a file so it is persistent
      echo > {var.filepath} "if exists(global."^{var.id}^")"
      echo >> {var.filepath} "    set global."^{var.id}^" = "^{var.value}
      echo >> {var.filepath} "else"
      echo >> {var.filepath} "    global "^{var.id}^" = "^{var.value}
      
      M98 P{var.filepath} ; load the global variable
      

      Working code:

      var id = param.V                    ; name of the global variable
      var value = param.X                 ; value to save
      var filepath = "globals/"^{var.id}  ; internal file path where the global variable is saved
      
      ; Save the global variable as a file so it is persistent
      echo >{var.filepath} "if exists(global."^{var.id}^")"
      echo >>{var.filepath} "    set global."^{var.id}^" = "^{var.value}
      echo >>{var.filepath} "else"
      echo >>{var.filepath} "    global "^{var.id}^" = "^{var.value}
      
      M98 P{var.filepath} ; load the global variable
      

      I just thought I'd pass this along.

      Using v3.6 rc1 & rc2 both produced the error.

      gloomyandyundefined dc42undefined 2 Replies Last reply Reply Quote 0
      • gloomyandyundefined
        gloomyandy @Gamefanatic3D
        last edited by

        @Gamefanatic3D Are you running in standalone mode or using an SBC?

        Gamefanatic3Dundefined 1 Reply Last reply Reply Quote 0
        • Gamefanatic3Dundefined
          Gamefanatic3D @gloomyandy
          last edited by

          @gloomyandy Stand-alone mode.

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

            @Gamefanatic3D that's correct, the syntax described at https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands#echo-command does not permit spaces after the > or >> or >>> symbol.

            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

            Gamefanatic3Dundefined 1 Reply Last reply Reply Quote 1
            • Gamefanatic3Dundefined
              Gamefanatic3D @dc42
              last edited by Gamefanatic3D

              @dc42 Tracking the syntax. However with the example at the bottom of the page not following the syntax it's not clear, so I thought it worth reporting such that either the "Examples of Use" section or the syntax would be updated.

              Saving and restoring variables across a reset

              • persistentGlobal.g
              • loadPersistentGlobal.g
              dc42undefined 1 Reply Last reply Reply Quote 0
              • dc42undefined
                dc42 administrators @Gamefanatic3D
                last edited by

                @Gamefanatic3D thanks, I have corrected the persistentGlobal.g example.

                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