CodeSOD: Four Sellers
by Remy Porter from The Daily WTF on (#6523V)
Andrew had to touch some Pascal code. Yes, really. He writes: "I came across this section of code today and really wanted to find out who wrote it. Then I really wanted to find out who added the comment."
{ Ugly code follows, a loop would be nice }{ Seller #1 }if not EOF thenbeginlsSName := FieldByName('txtname').AsString;if Length(FieldByName('txtsname').AsString) > 0 thenbeginlsSName := Concat(lsSName,', ' + FieldByName('txtsname').AsString);end;Next;sctevarS1Name.AsString := lsSName;endelsebeginClose;Exit;end; { else }{ Seller #2 }if not EOF thenbeginlsSName := FieldByName('txtname').AsString;if Length(FieldByName('txtsname').AsString) > 0 thenbeginlsSName := Concat(lsSName,', ' + FieldByName('txtsname').AsString);end;Next;sctevarS2Name.AsString := lsSName;endelsebeginClose;Exit;end; { else }{ Seller #3 }if not EOF thenbeginlsSName := FieldByName('txtname').AsString;if Length(FieldByName('txtsname').AsString) > 0 thenbeginlsSName := Concat(lsSName,', ' + FieldByName('txtsname').AsString);end;Next;sctevarS3Name.AsString := lsSName;endelsebeginClose;Exit;end; { else }{ Seller #4 }if not EOF thenbeginlsSName := FieldByName('txtname').AsString;if Length(FieldByName('txtsname').AsString) > 0 thenbeginlsSName := Concat(lsSName,', ' + FieldByName('txtsname').AsString);end;Next;sctevarS4Name.AsString := lsSName;endelsebeginClose;Exit;end; { else }
Yes, a loop would have been nice. Pity we couldn't do that, for some reason.
[Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today!