You need to round them off or truncate them to a certain number of decimals. I haven't used Qbasic, so can't tell you how to do it.
I have a program written in basic that generates gcode based on user input. my problem is sometimes the output looks like this:
G0 X 4.525002 Y-1.400002
Their is no reason that .000002 should be added to these numbers, it just randomly appears.
All of my variables are dimensioned as single
can anyone help?
Similar Threads:
You need to round them off or truncate them to a certain number of decimals. I haven't used Qbasic, so can't tell you how to do it.
Gerry
UCCNC 2017 Screenset
[URL]http://www.thecncwoodworker.com/2017.html[/URL]
Mach3 2010 Screenset
[URL]http://www.thecncwoodworker.com/2010.html[/URL]
JointCAM - CNC Dovetails & Box Joints
[URL]http://www.g-forcecnc.com/jointcam.html[/URL]
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
If you want to post the qbasic program here, I'll take a look and let you know where to round it at.
Matt
San Diego, Ca
___ o o o_
[l_,[_____],
l---L - □lllllll□-
( )_) ( )_)--)_)
(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Dimension as single is probably causing the slight rounding error.
When you output the line use a statement like:
PRINT USING "#####.###"; X;
Bill
Here is the file
how would I format output when the print statement looks like this:
PRINT #1, "G0 X"; X(m) - XA - 1.875; " Y"; RT(j, m) - YA - .75
Its a pretty long program, the first few pages are just menu commands though.
try this:
format$="\ \ #####.### \ \ #####.###"
PRINT #1, USING format$ "G0 X"; X(m) - XA - 1.875; " Y"; RT(j, m) - YA - .75
I use
Print #1, format$(num,"##.0000")
nevermind... the above is for Visual Basic
You could use 'INT'
eg.
X = INT(X*1000+.5)/1000
Y= INT(Y*1000+.5)/1000
This will round to three decimal places.