Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: neilrlw on May 24, 2016, 05:20:38 PM
-
I need a macro for a button that if pressed will ask for a new file name and then change the current saved g-code file name (e.g., circle.tap) to that new name. For instance, I create a G-code file using the Code command, then load that file. I want to then change the name of this file from circle.tap to circle1.tap. I tried to do this with the FILENAME command but must be doing something wrong. Can anyone suggest the correct syntax?
Thanks in advance.
-
Hi neilrlw,
I'm very new at this so it may not help....
This is part of a script I wrote to introduce a correction into a Gcode file.
Note I used a fixed path to a file in myDocuments. Then used a dialog box
to get the name of the specific Gcode file, opened it as input and created
a new file with 'CORRECTED' inserted in the original name as output.
pathname="C:\Users\craig\Documents\eagle\lvdt2\"
Begin Dialog filenameinput 16,30,180,96,"filename input"
OKButton 132,20,40,14
Text 8,8,32,8,""
TextBox 8,20,100,12,.inputname
End Dialog
Dim Dlg1 As filenameinput
Dialog Dlg1
origname=pathname & Dlg1.inputname
modname=pathname & "CORRECTED" & Dlg1.inputname
It might be a dirty trick but you could do similar
pathname="C:\.........(to your file directory of interest)"
Use a textbox to get the name of the specific file you want...
The complete filename would be...
origname=pathname&Dlg1.inputname 'inputname="circle.tap" for instance
and the modified filename could be....
modname=pathname & "MODIFIED" &Dlg1.inputname
Now open the original as input and the modified as output and copy line by line
until the end of the file...
Open origname For Input As #1
Open modname For Output As #2
While Not EOF(1)
Line Input #1, currline
Print #2,currline
Wend
As I say it is a cheap and dirty trick but it worked. There was of course a bit more code
within the body of the loop to effect the correction I needed to make but still it worked.
Craig