- Posts: 3981
- Thank you received: 994
if/while ?
- BigJohnT
- Offline
- Administrator
-
John
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
but now you threw in "if" and "lt" (guessing "less than")
i understand that "if "this" is "less than" "that" do something.
but i can't see where it(while) knows to move xy or z.
Thanks again !
BigJohnT wrote:
There are quite a few examples in the subroutines section of the do while loop.
Here is one from the ID subroutine.
o100 while [#<Current-Diameter> lt #<Final_Dia>]
O101 if [#<Current-Diameter> + #<Depth_Cut> lt #<Final_Dia>]
#<Current-Diameter> = [#<Current-Diameter> + #<Depth_Cut>]
O101 else
#<Current-Diameter> = #<Final_Dia>
O101 endif
X#<Current-Diameter>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current-Diameter>-0.010]
Z#<Z_StartOfCut>
o100 endwhile
John
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
-
- Posts: 3981
- Thank you received: 994
G0 X[3 + 5]
would send the X axis to X8
John
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
-
- Posts: 3981
- Thank you received: 994
www.linuxcnc.org/docview/html/gcode_over...html#sub:Expressions
The basic syntax of a while loop is:
while test is true
do code between while and endwhile
endwhile
So when the while test evaluates to false jump to the endwhile line. and carry on without executing any code between while and endwhile.
John
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
it could be G0 x[3+5+9-10] and X would go to 7
BigJohnT wrote:
The [a + c + d] the equation inside of the square brackets is evaluated and the result is returned so,
G0 X[3 + 5]
would send the X axis to X8
John
Please Log in or Create an account to join the conversation.
- piasdom
- Offline
- Banned
-
- Posts: 145
- Thank you received: 9
i don't understand how the "while" knows which to move, xy or z.
and i'll got look at these binaries. thanks for that.
as in this example;
o100 while [#<Current-Diameter> lt #<Final_Dia>]
O101 if [#<Current-Diameter> + #<Depth_Cut> lt #<Final_Dia>]
#<Current-Diameter> = [#<Current-Diameter> + #<Depth_Cut>]
O101 else
#<Current-Diameter> = #<Final_Dia>
O101 endif
X#<Current-Diameter>
G1 Z#<Z_EndOfCut> F#<FeedRate>
G0 X[#<Current-Diameter>-0.010]
Z#<Z_StartOfCut>
o100 endwhile
BigJohnT wrote:
Here is the binary operators like LT
www.linuxcnc.org/docview/html/gcode_over...html#sub:Expressions
The basic syntax of a while loop is:
while test is true
do code between while and endwhile
endwhile
So when the while test evaluates to false jump to the endwhile line. and carry on without executing any code between while and endwhile.
John
Please Log in or Create an account to join the conversation.