Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: birillo1959 on July 25, 2022, 02:35:19 AM
-
good morning
I found on the net this macro stores x axis in the file
since I am not capable of it, is it possible to modify it for all the axes? possibly for "X and Y". I thank those who can help me!
This example creates a file called myFile.txt in the Mach3 folder. It then reads the current position of the X-axis and writes it to the file. Lastly it closes the file.
Dim X as Double
Open "C:\Mach3\myFile.txt" For Output As #1
X = GetDRO(0)
Print #1, X
Close #1
And here's code that opens the file created in the previous example and reads a single line from it. It then asks the user if it's OK to move the X-axis to the position stored in the file.
Dim Answer
Dim newPos As Double
Open "C:\Mach3\myFile.txt" For Input As #2 'Open the file for reading
Line Input #2, newPos 'Read the first line of the file
Answer = MsgBox ("Is it OK to move the X axis to: " & newPos & "?", 1)
If Answer = 1 Then 'You pressed OK
Code "G0 X"& newPos 'Make the move
End If
Close #2 'Close the file
-
This is an ideal learning opportunity for you. Most of the clues you need are there in the macro you already have.
-
John Haine thanks for the answer, tried and tried again I don't come to the head, I know it could be easy to modify it but I'm not really capable !!!! programming are at 0, even less !! :( :(
-
Dim X,Y as Double
Open "C:\Mach3\myFile.txt" For Output As #1
X = GetDRO(0)
Y = GetDRO(1)
Print #1, X
Print #1, Y
Close #1
Dim Answer
Dim newPosX, newPosY As Double
Open "C:\Mach3\myFile.txt" For Input As #2 'Open the file for reading
Line Input #2, newPosX 'Read the first line of the file
Line Input #2, newPosY 'Read the second line of the file
Answer = MsgBox ("Is it OK to move the X axis to: " & newPos & "?", 1)
If Answer = 1 Then 'You pressed OK
Code "G0 X"& newPosX & " Y" & newPosY 'Make the move
End If
Close #2
NOT TESTED
-
Good morning
Thanks for your help.
I tested it and it works perfectly, only problem (if you can 'define what i' !!) in the file, after the point, it stores too many numbers
22.000000003381
32.999999998041
I don't know if it can be changed, but it's irrelevant.
thanks TPS for the help offered !!!!!
-
we had the same couple of day's ago:
Dim X,Y as Double
Open "C:\Mach3\myFile.txt" For Output As #1
X = GetDRO(0)
Y = GetDRO(1)
Print #1, nFmt(X,4)
Print #1, nFmt(Y,4)
Close #1
-
perfect!!!! everything works great !!
sorry if I abuse your patience but programming are at 0 (even something less :()
greetings and thanks :)