1. Dunno what the topic should be other than it works and i'm a bit burnt out

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=3D1 to length(fieldlist[dupf][5]) by 4 do
		if fieldlist[dupf][5][k+2]=3Dddata[3]=20
		and fieldlist[dupf][5][k+1]=3Drli then
		if fieldlist[dupf][5][k+3][2]=3D0 then
			fieldlist[dupf][5][k+3][2]=3Dfli

-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D-

Can't believe I did that; Can't believe it works...
But I did, there you have it, colour me stupid.

-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D-

I have started the correcting process with eg:
constant F_Face=3D1, F_Size=3D2, F_Attr=3D3, F_Clr=3D4, F_Uniq=3D5
.....
	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])})

-=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D-
That's a bit clearer. Rectifying the rest of the code...

Stepwise, test again at every step, pencil and paper job, I guess.=20

Otherwise does anyone have any tips on converting gibberish but
working code back to something readable without breaking it?

Yours hopefully,
Pete (obviously a bit deranged and doing some odd self-humiliation
therapy, or something !)

new topic     » topic index » view message » categorize

2. Re: Dunno what the topic should be other than it works and i'm a bit burnt out

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Dunno what the topic should be other than it works and i'm a bit burnt out

On Thu, 13 Feb 2003 11:01:23 +1100, Derek Parnell
<ddparnell at bigpond.com> wrote:

>You mean apart from getting someone else to do it?
Shucks
Actually after 3 hours away from the keyboard the solution presented
itself: just walk down the code popping in little comments of the form

-- L_pos=3D2

-- L_text=3D3

Then collect them all up (leaving them in place), copy and sort them
at the top of the program till they make sense, search/replace any
that don't as you go, and its not so hard. Just remember to keep
re-testing the program every two minutes.

Hopefully someone (subconsciously) learnt how not to write code...

Pete

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu