QBASIC programmers - need help!


Results 1 to 8 of 8

Thread: QBASIC programmers - need help!

  1. #1
    Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    421
    Downloads
    0
    Uploads
    0

    Default QBASIC programmers - need help!

    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:


  2. #2
    Member ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    35538
    Downloads
    1
    Uploads
    0

    Default

    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)


  3. #3
    Registered Rekd's Avatar
    Join Date
    Apr 2003
    Location
    teh Debug Window
    Posts
    1876
    Downloads
    0
    Uploads
    0

    Default

    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)


  4. #4
    Member wjbzone's Avatar
    Join Date
    Apr 2003
    Location
    United States
    Posts
    416
    Downloads
    0
    Uploads
    0

    Default

    Dimension as single is probably causing the slight rounding error.

    When you output the line use a statement like:
    PRINT USING "#####.###"; X;

    Bill



  5. #5
    Member
    Join Date
    Aug 2004
    Location
    USA
    Posts
    421
    Downloads
    0
    Uploads
    0

    Default

    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.

    Attached Files Attached Files


  6. #6
    Member wjbzone's Avatar
    Join Date
    Apr 2003
    Location
    United States
    Posts
    416
    Downloads
    0
    Uploads
    0

    Default

    try this:

    format$="\ \ #####.### \ \ #####.###"
    PRINT #1, USING format$ "G0 X"; X(m) - XA - 1.875; " Y"; RT(j, m) - YA - .75



  7. #7
    Registered
    Join Date
    May 2005
    Location
    USA
    Posts
    36
    Downloads
    0
    Uploads
    0

    Default

    I use

    Print #1, format$(num,"##.0000")


    nevermind... the above is for Visual Basic



  8. #8
    Member
    Join Date
    Jul 2003
    Location
    New Zealand
    Posts
    1220
    Downloads
    0
    Uploads
    0

    Default

    You could use 'INT'
    eg.
    X = INT(X*1000+.5)/1000
    Y= INT(Y*1000+.5)/1000
    This will round to three decimal places.



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

QBASIC programmers - need help!

QBASIC programmers - need help!