CodeSOD: Join Us Again

This post was originally published on this site

The Daily WTF

Submitter “Anonymouse Lee” inherited a Pascal program that started its development back in 2002. It’s seen some rough handling over the years, and that alone has bred some WTFs, but this particular block was created by the founder of the company, who bills themself as a “highly technical founder”.

The goal is this: the program needs to display a data grid, and depending on the recordType of each row in the grid, that row needs to be displayed slightly differently.

Let’s take a look at the code:

var x,y : int; recordtypes : variant; begin recordtypes := sql(‘select key_value, code from recordType’); for x := 0 to grid.RecordCount – 1 do begin for y := 0 to hi(recordtypes,2) do begin if grid[x].key_value = recordtypes[0,y] then case recordtypes[1,y] of ‘a’: begin *do stuff for type ‘a’ here* break; end; ‘b’: begin *do stuff for type ‘b’ here* break; end; ‘c’: begin

To read the full article click on the 'post' link at the top.