On Friday 03 October 2014 05:29:11 andy pugh did opine And Gene did reply: > On 3 October 2014 08:08, alex chiosso <achio...@gmail.com> wrote: > > I wonder to know how difficult is to implement the GOTO logical > > operators within the LCNC G Code interpreter. > > The first question is how you would define the target position. As > LinuxCNC G-code doesn't pay attention to line numbers I think you > would need two new keywords, both the GOTO expression and the target. > O100 LABEL maybe? > > In the interpreter at the moment the loop ends are matched by number. > O100 while -> O100 endwhile etc. In the context of GOTO it guess that > you would need an O101 GOTO to jump to your O101 LABEL. > > But, this leaves no scope for the (I shudder to mention this even > amongst GOTO advocates) computed GOTO. O[#1 + 200] GOTO isn't valid > syntax, I don't think. > > As a less-than-transparent workaround you can currently use O100 WHILE > [0] to jump to an O100 ENDWHILE, but I don't know if you can jump > backwards, and I don't know if you can have more than one WHILE per > ENDWHILE. > > For many of the applications that have been mentioned here, the O100 > REPEAT[] statement will work.
This discussion is interesting. I guess you could say I learned all sorts of bad habits in the late 70's when I wrote, in machine code entered via a hex monitor on an RCA COSMAC based board, and I still have a copy of that code on paper on the top shelf, a program to put the queue and next tones on a commercial tape. I committed nearly every programming error now frowned on. Because static ram was $100 a kilobyte then (I built a 4 k ram board from a kit, along with the S-100 buss backplane it needed) I was not free to write "run once" code. So the list of programming no-no's was extensive, but at that point I had not ever seen a machine running a higher level language that didn't have 12,000 12au7 vacuum tubes in it. I had no assembler, I was looking up the hex code for the next instruction in the RCA published programmer's manual for the 1802 processor. So I: 1. used self modifying code just so I could re-run a loop with different data 2. used jumps liberally as that chip didn't have a call or return, those were actually short loops you initialized a different register to, and were used easily because any of its 16, 16 bit registers could become the program counter with 1 byte commands. 3. at the end, restored the modifications it made to itself before jumping back to the start to await the next button pushes on the operators pendant I also built. 4. Left good docs so the next guy might understand it in the event the next generation of tape machine it might be asked to control had different "ballistics". This thing did a job that no other machine was capable of doing because no one realized that what it did was needed to be done, so it was not available in the broadcast oriented maker market. At 2 or 3 points I even considered going into business making it, but that market was for a maximum of under 1000 here in the states, so that never got to the how much $ would I need to get started point. The Production dept has just been completed on a new commercial, and its handed off to the people in the control room, to air on the schedule set by the traffic dept. But you've got an "automatic station break" machine controller, one that uses an audio tone on the 2nd audio channel to trigger what it does. These nominally 1 second tones need to be at "first video" -5 seconds, and again at the end of the commercial -5 seconds so if there is another commercial scheduled in the currant break, it can be started rolling and will be switched to when the 5 seconds is up. So this computer could drive the machine frame by frame in either direction, mark that frame as the first air frame by hitting another button of several that told it how long the commercial was (I rigged it for 10-15-30-60 & 2:00 minutes with different buttons) and allowed the 30 to be 29 secs & 25 frames, that 5 frames pulled off everything. My program also drove a character generator I built with big enough characters which could also put a new, frame accurate "academy leader", the countdown clock on the tape so the guys whose reflexes were good enough could cue the tape up themselves. I demanded power failure restoration to power failure restoration stability, even building in a UPS of sorts to cover short term glitches. That I got, and that little COSMAC (actually a Quest Elf) did that job, lowering the "make goods" by 90%, and was still doing it 15 years later when I last checked. In broadcasting, the tech marches on as it does, so to hear that it was still in use 15 years later sure put a VBWG on my face. But so far, and I've done a lot of while/endwhile loops in my code, I have not missed having a goto. The control structures we have are IMO more than sufficient to write the compact gcode that "gets the job done". To me it beats the hell out of the gcode generators we have as none of then has (not that I have seen anyway) been able to generate a reusable many times loop of code. Just because I could, I have written 90 lines of gcode that took 2 days to run. A gcode generator would have generated it all in line, 100 megabytes or more. You cannot readily adjust that code to fix a minor error, but that 90 liner can be adjusted in an editor in 2 minutes. So, life is good, and its good without a goto. And this was one heck of a long winded yet still not enough detail, way to so that I do not, and never will, miss a goto. I haven't a clue what I would use it for in gcode. Cheers, Gene Heskett -- "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) Genes Web page <http://geneslinuxbox.net:6309/gene> US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users