Re: Dunno what the topic should be other than it works and i'm a bit burnt out
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 13, 2003
- 389 views
On Wed, 12 Feb 2003 23:31:06 +0000, Pete Lomax <petelomax at blueyonder.co.uk> wrote: > > I've just spent the last 2 days **hacking** and it works, but... > > I have ended up with code like the following: > > printf(1," Printed:%d Rec:%d Fld:%d (%s%s:%d) Prev:%d Next:%d\n", > fieldlist[i][5][k..k+2]&ddata[1..3]&fieldlist[i][5][k+3]) > > (Yes, I went a bit mad & I guess I'm a bit lucky there are a few debug > prints left which give *me* clues to code *I just wrote* - not even 48 > hours old... Why [5]? Why [k..k+2]? etc...) > > Worse: > for k=1 to length(fieldlist[dupf][5]) by 4 do > if fieldlist[dupf][5][k+2]=ddata[3] and fieldlist[dupf][5][k+1]=rli > then > if fieldlist[dupf][5][k+3][2]=0 then > fieldlist[dupf][5][k+3][2]=fli > > -==================================================- > > Can't believe I did that; Can't believe it works... > But I did, there you have it, colour me stupid. > > -==================================================- > > I have started the correcting process with eg: > constant F_Face=1, F_Size=2, F_Attr=3, F_Clr=4, F_Uniq=5 > ..... > printf(1,"Face:%s Pitch:%d Attributes:%s Colour:%s\n", > {font[F_Face], > font[F_Size], > get_attr_desc(font[F_Attr]), > get_colour_desc(font[F_Clr])}) > > -==================================================- > That's a bit clearer. Rectifying the rest of the code... > > Stepwise, test again at every step, pencil and paper job, I guess. > > Otherwise does anyone have any tips on converting gibberish but > working code back to something readable without breaking it? You mean apart from getting someone else to do it? No. It's a hard slog from here. HOwever I can recommend that you spend some serious time getting your naming convention right. It doesn't matter what you accept as your naming convention - but you should have one! Also, I have a library that helps a bit with this sort of 'constant' assignments. Using the example above I'd write... include series.e . . . constant sFont = next_number("structs"), F_Face= next_number(sFont), F_Size= next_number(sFont), F_Attr= next_number(sFont), F_Clr = next_number(sFont), F_Uniq= next_number(sFont), SizeofFont = current_number(sFont) . . . printf(1,"Face:%s Pitch:%d Attributes:%s Colour:%s\n", {font[F_Face], font[F_Size], get_attr_desc(font[F_Attr]), get_colour_desc(font[F_Clr])}) -- cheers, Derek Parnell