String will return a G-Code formatted string.
()
| 33 | |
| 34 | // String will return a G-Code formatted string. |
| 35 | func (l *Line) String() string { |
| 36 | // prepare string |
| 37 | s := "" |
| 38 | |
| 39 | // write all codes |
| 40 | for i, c := range l.Codes { |
| 41 | // add space if any codes have been already added |
| 42 | if i > 0 { |
| 43 | s = s + " " |
| 44 | } |
| 45 | |
| 46 | // add string |
| 47 | s = s + c.String() |
| 48 | } |
| 49 | |
| 50 | // write comment if existing |
| 51 | if l.Comment != "" { |
| 52 | // write space if any codes have been written |
| 53 | if len(l.Codes) > 0 { |
| 54 | s = s + " " |
| 55 | } |
| 56 | |
| 57 | // add comment |
| 58 | s = s + fmt.Sprintf(";%s", l.Comment) |
| 59 | } |
| 60 | |
| 61 | // add line feed |
| 62 | s = s + "\n" |
| 63 | |
| 64 | return s |
| 65 | } |
| 66 | |
| 67 | // A File contains multiple lines of G-Codes. |
| 68 | type File struct { |
no outgoing calls