if/while ?

More
01 Mar 2012 16:27 - 01 Mar 2012 16:36 #18237 by ArcEye
Replied by ArcEye on topic Re:if/while ?
Hi

You have reversed logic.

You are taking 1 away from #<start> each time instead of adding to it.
You are testing if #<start> is GE to #<final_distant> (6) and it never was and won't be.

This will do what you intended
g17 g20 g40 g49 g54 g80 g90 g94 g92.1

#<start> = 0
#<travel_ing> = 1
#<final_distant> = 6
#<feed_rate> = 18

o100 do
    #<start> = [#<start> + #<travel_ing>]
    g1 f#<feed_rate> x#<start>
    G01 x0
o100 while [#<start> LE #<final_distant>]

m2
NB.
do / while loops are used where you have a reason to want the first iteration to occur whatever and then make a conditional test after that

A normal while loop would do here with slight logic alteration, ie
g17 g20 g40 g49 g54 g80 g90 g94 g92.1

#<start> = 0
#<travel_ing> = 1
#<final_distant> = 6
#<feed_rate> = 180

o100 while [#<start> LT #<final_distant>]
    #<start> = [#<start> + #<travel_ing>]
    g1 f#<feed_rate> x#<start>
    G01 x0
o100 endwhile

m2

regards
Last edit: 01 Mar 2012 16:36 by ArcEye.

Please Log in or Create an account to join the conversation.

More
01 Mar 2012 16:56 #18238 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks ArcEye, don't know why i can't get this.
But thanks for fixing my problem.(program anyway:)

Please Log in or Create an account to join the conversation.

More
02 Mar 2012 14:37 #18260 by piasdom
Replied by piasdom on topic Re:if/while ?
Thanks for the help !
attached is what i ended up with to help others.

File Attachment:

File Name: DoWhile.ngc
File Size:1 KB
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.079 seconds
Powered by Kunena Forum