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

    Why does the forum add {1} into CODE

    Scheduled Pinned Locked Moved
    Off Topic
    5
    7
    479
    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.
    • OwenDundefined
      OwenD
      last edited by

      I've found that often when copying and pasting things into CODE blocks, the forum adds {1} into areas where there is a line break.
      But not always?
      I've tried setting my the temp editor to use Linux style line breaks (CR) instead of (CR/LF), but I can't seem to crack what the cause is and more importantly how to avoid it?

      1 Reply Last reply Reply Quote 0
      • Phaedruxundefined
        Phaedrux Moderator
        last edited by

        That's a good question. Sometimes it seems to do it, and sometimes not.

        If you have a sample of copy and paste that can reliably cause it can you upload that file?

        Z-Bot CoreXY Build | Thingiverse Profile

        OwenDundefined 1 Reply Last reply Reply Quote 0
        • OwenDundefined
          OwenD @Phaedrux
          last edited by

          @phaedrux

          I think I've worked it out.
          It's a bug in the syntax highlighter.
          It seems to occur on any line break following a quoted string "some text"
          This is original where some lines have quoted text as is required.

          if move.axes[0].homed !=true || move.axes[1].homed !=true || move.axes[2].homed !=true
          	echo "Homing"
          	M291 P"Homing required.  Please wait" R"Homing" S1 T3
          	G28 ; home all if required
          
          echo "Creating cold bed map"
          M291 P"Creating cold bed map" R"Cold Map" S1 T3
          G29 S0 ; create bed mesh
          if result !=0
          	M140 S0 R0 ; set active and standby temps to zero
          	M140 S-276 ; turn off bed
          	abort "Failed to create height map"
          
          G29 S3 P{var.ColdBedMap} ; save mesh to separate file
          
          if result !=0
          	abort "Failed to create height map"
          
          G29 S2 ; clear height map
          
          echo "Heating for nextmap"
          M291 P"Heating for next map" R"Heating" S1 T3
          M190 R{var.LowTemp}
          M116 H0 S{var.TempTolerance}; wait for any temp changes on bed to be within X degrees of target
          echo "waiting for temp to stabilise"
          G4 S{var.SoakTime}
          echo "Creating low temp bed map"
          M291 P"Creating low temp bed map" R"Low Temp Map" S1 T3
          G29 S0 ; create bed mesh
          

          VS
          This is same code with all " charectors replaced by *

          if move.axes[0].homed !=true || move.axes[1].homed !=true || move.axes[2].homed !=true
          	echo *Homing*
          	M291 P*Homing required.  Please wait* R*Homing* S1 T3
          	G28 ; home all if required
          
          echo *Creating cold bed map*
          M291 P*Creating cold bed map* R*Cold Map* S1 T3
          G29 S0 ; create bed mesh
          if result !=0
          	M140 S0 R0 ; set active and standby temps to zero
          	M140 S-276 ; turn off bed
          	abort *Failed to create height map*
          G29 S3 P{var.ColdBedMap} ; save mesh to separate file
          
          if result !=0
          	abort *Failed to create height map*
          
          G29 S2 ; clear height map
          
          echo *Heating for nextmap*
          M291 P*Heating for next map* R*Heating* S1 T3
          M190 R{var.LowTemp}
          M116 H0 S{var.TempTolerance}; wait for any temp changes on bed to be within X degrees of target
          echo *waiting for temp to stabilise*
          G4 S{var.SoakTime}
          echo *Creating low temp bed map*
          M291 P*Creating low temp bed map* R*Low Temp Map* S1 T3
          G29 S0 ; create bed mesh
          
          OwenDundefined 1 Reply Last reply Reply Quote 1
          • OwenDundefined
            OwenD @OwenD
            last edited by

            @owend

            In further news, I recalled that you can set the syntax file the highlighter used
            e.g

            ```perl
            gcode here
            ```
            

            This seems to fix the issue using pretty much any syntax language file I could guess
            e.g.
            bash
            perl
            python
            json

            Perhaps it would be wise to change the default that the forum uses to avoid this issue.

            This one uses perl

            if move.axes[0].homed !=true || move.axes[1].homed !=true || move.axes[2].homed !=true
            	echo "Homing"
            	M291 P"Homing required.  Please wait" R"Homing" S1 T3
            	G28 ; home all if required
            
            echo "Creating cold bed map"
            M291 P"Creating cold bed map" R"Cold Map" S1 T3
            G29 S0 ; create bed mesh
            if result !=0
            	M140 S0 R0 ; set active and standby temps to zero
            	M140 S-276 ; turn off bed
            	abort "Failed to create height map"
            G29 S3 P{var.ColdBedMap} ; save mesh to separate file
            
            if result !=0
            	abort "Failed to create height map"
            
            G29 S2 ; clear height map
            
            echo "Heating for nextmap"
            M291 P"Heating for next map" R"Heating" S1 T3
            M190 R{var.LowTemp}
            M116 H0 S{var.TempTolerance}; wait for any temp changes on bed to be within X degrees of target
            echo "waiting for temp to stabilise"
            G4 S{var.SoakTime}
            echo "Creating low temp bed map"
            M291 P"Creating low temp bed map" R"Low Temp Map" S1 T3
            G29 S0 ; create bed mesh
            
            
            droftartsundefined o_lampeundefined 2 Replies Last reply Reply Quote 2
            • droftartsundefined
              droftarts administrators @OwenD
              last edited by

              @owend thanks for working this out! It’s been bugging me for a while. Perhaps @T3P3Tony can do something about it?

              Ian

              Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

              1 Reply Last reply Reply Quote 0
              • o_lampeundefined
                o_lampe @OwenD
                last edited by o_lampe

                @owend
                Good catch Owen!
                I read lately, that some guy wrote a gcode syntax highlighter for the forum. I didn't knew what that meant, so forgot mostly about it. Would be interesting to try that one in this context.

                //edit found him

                1 Reply Last reply Reply Quote 0
                • T3P3Tonyundefined
                  T3P3Tony administrators
                  last edited by T3P3Tony

                  @droftarts et al

                  I have worked out a work around for this - it should prevent future code blocks from having the issue - but will not go back and replace existing code in existing posts.

                  I think this is limited to some keywords within the quotes as well as the quotes them selves and is a bug with the SQL and PHP autodetection highlighter line numbers are set:

                  1d132169-94b1-47eb-be18-66b8ba49bc55-image.png

                  Turn of line number for SQL and PHP:

                  96db78ab-9572-4f5d-b61d-828752ee2171-image.png

                  so since we don't post SQL/PHP on this forum then turning off the line numbering wont impact anyone .

                  If the autodetection detects your post code as SQL/PHP then force it to be JSON or something

                  
                  "special words & order: map, create "
                  
                  arbitrary text 
                  
                  

                  .

                  www.duet3d.com

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