Are nested subroutines possible?

01 Oct 2018 19:28 #118313 by andypugh

eneias_eringer wrote:

andypugh wrote: Something that you didn't mention is what version of LinuxCNC you are using.

The M98 / M99 subroutine format was only added to the LinuxCNC development branch very recently (for compatibility with some other controls). Is that the version you are using?

Really ??? !!! and a GOTO will be implanted too ??? LOL !!!

I am not sure what you are saying.
LinuxCNC has had subroutines and flow control statements for a very long time.
The recent development just adds M98 / M99 as an alternative format to achieve the same thing.
03 Oct 2018 14:14 #118410 by eneias_eringer
Yes i use the statements so much and it works very well but sometimes a simple goto was better.

When i need a "GOTO" i put like this:


03 Oct 2018 21:10 - 03 Oct 2018 21:22 #118422 by Grotius
Hi Eneias,

If you read the C doc's you see goto statement's are not preferred to use.

One google of this : The goto statement is rarely used because it makes program confusing, less readable and complex. Also, when this is used, the control of the program won’t be easy to trace, hence it makes testing and debugging difficult.

Better is to use a procedure that read's continue.
I have a example code for you :

The program start's with a template, the variable numbers are for fun :
The the program has no goto statement's :

In my C code i use only a Goto if there is no other option :
Line 238 for restart attempts.

I hope this info is usefull for you !
Last edit: 03 Oct 2018 21:22 by Grotius.
08 Oct 2018 19:10 #118553 by eneias_eringer
thankyou !!!

I agree that is better to not use goto !!!

but my point is , all cnc controllers have a normal goto , so when you have to convert a code , is very hard !!!
In example , try to convert a Renishaw code , is easyer to write a new just becouse we dont have a goto !!
Time to create page: 0.078 seconds
Powered by Kunena Forum