-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGcodeEditorSub
More file actions
42 lines (29 loc) · 983 Bytes
/
GcodeEditorSub
File metadata and controls
42 lines (29 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Sub editGcode()
'define vars
Dim InputFileName As String
Dim OutputFileName As String
Dim TargetString As String
Dim NewString As String
Dim TextFile As Integer
Dim FileContent As String
'get address of input and output files
InputFileName = "C:\Users\Ericw\Desktop\pumpkinTest3.gc"
OutputFileName = "C:\Users\Ericw\Desktop\pumpkinTest3_edit.gc"
'define file we are opening as freefile
TextFile = FreeFile
'open file and mark it as TextFile
Open InputFileName For Input As TextFile
'Store file content inside a variable
FileContent = Input(LOF(TextFile), TextFile)
'Close Text File
Close TextFile
'Find/Replace necessary lines
FileContent = Replace(FileContent, "M106 S204", "G4 P25" & vbNewLine & "M106 S204")
FileContent = Replace(FileContent, "M106 S0", "M106 S0" & vbNewLine & "G4 P25")
TextFile = FreeFile
Open OutputFileName For Output As TextFile
'Write New Text data to file
Print #TextFile, FileContent
'Close Text File
Close TextFile
End Sub