Re: A Puzzle in Eu -- what would you do?
- Posted by Jason Gade <jaygade at yahoo.com> Aug 05, 2005
- 500 views
Jason Gade wrote: > > Bernie Ryan wrote: > > > > > > sequence ctr ctr = {1} > > > > while 1 do > > ctr &= match("--",line[ctr[$]..$]) > > if ctr[$] = 0 then exit endif > > end while > > > > ctr now equals a list of all the locations of the "--" in the line. > > so from there you can figure out where the real comment is. > > > > Hit the keys too fast > > > > Bernie > > > > My files in archive: > > w32engin.ew mixedlib.e eu_engin.e win32eru.exw > > > > Can be downloaded here: > > <a > > href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a> > > > > Bernie, your code went into an infinite loop for me. Try this slightly more > complicated > version below: > }}} <eucode> > sequence line, ctr > integer here > > line = "there are no -- comments -- in this thing -- here" > ctr = {0} > > while 1 do > here = match("--", line[ctr[$]+1..$]) > if here = 0 then exit end if > ctr &= here + ctr[$] > end while > ? ctr > <font color="#330033"></eucode> {{{ </font> > > With your code it gets stuck in an infinite loop with ctr = > {1,14,1,14,1,14...} > > ================================================================ > "Actually, I'm sitting on my butt staring at a computer screen." > - Tom Tomorrow > > j. > of course for comments that start with '----' you get a number for every match. Maybe a for loop increasing the index by 2... ================================================================ "Actually, I'm sitting on my butt staring at a computer screen." - Tom Tomorrow j.