Page 1 of 1

loop cycle?

PostPosted: Tue Jun 06, 2017 8:45 pm
by Raider192
How do I run a loop in a program? Is it in the realm of WHILE and END WHILE? If so, what is the correct format?
Thanks for your help?

Re: loop cycle?

PostPosted: Tue Jun 06, 2017 8:54 pm
by dezsoe
What do you mean by program? Is it g-code or macro? Do you need conditional cycle?

Re: loop cycle?

PostPosted: Tue Jun 06, 2017 9:38 pm
by cncdrive
The syntax is C#, it is a C based language with some more object orientation than Ansi C.
C# does not use the END word at all, the END statement is used by Basic and Pascal language for example.

A while statement in C# can look like:

while(condition test)
{
//Do something
}

do
{
//Do something
}
while(condition test);

With the first one the condition is tested at the beginning, so if the condition check is false then the cycle does not run at all,
and the second type tests the condition at the end, so with this one the cycle runs at least once even if the condition was false from the beginning.

For the syntax of different things in C# I advice you to read after the C# language. It is one of the worlds' most popular programming languages today, so you can find lots of informations about it online.

Re: loop cycle?

PostPosted: Tue Jun 06, 2017 9:44 pm
by cncdrive
I was talking about macros and plugins in my previous post.
If you want to add loops in your g-code file then you may use subroutines M98/M99,
or you may call macros which running the loops inside the macro code.