if/while ?

More
14 years 7 months ago #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
Code:
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
Code:
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

Please Log in to join the conversation.

  • piasdom
  • Topic Author
  • New Member
  • New Member
More
14 years 7 months ago #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 to join the conversation.

  • piasdom
  • Topic Author
  • New Member
  • New Member
More
14 years 7 months ago #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.

Attachment DoWhile.ngc not found

Please Log in to join the conversation.

Time to create page: 0.143 seconds
Powered by Kunena Forum