MCPcopy Create free account
hub / github.com/256dpi/gcode / String

Method String

gcode.go:35–65  ·  view source on GitHub ↗

String will return a G-Code formatted string.

()

Source from the content-addressed store, hash-verified

33
34// String will return a G-Code formatted string.
35func (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.
68type File struct {

Callers 2

TestWriteFileFunction · 0.45
WriteFileFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestWriteFileFunction · 0.36