Click here to Skip to main content
15,889,595 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Simple yet entertaining Pin
Shameel26-Nov-09 23:18
professionalShameel26-Nov-09 23:18 
GeneralRe: Simple yet entertaining Pin
wout de zeeuw26-Nov-09 23:21
wout de zeeuw26-Nov-09 23:21 
GeneralRe: Simple yet entertaining Pin
Shameel27-Nov-09 5:29
professionalShameel27-Nov-09 5:29 
GeneralRe: Simple yet entertaining Pin
wout de zeeuw27-Nov-09 5:47
wout de zeeuw27-Nov-09 5:47 
Generalwhere's waldo? Pin
Wes Jones4-Nov-09 14:26
Wes Jones4-Nov-09 14:26 
GeneralRe: where's waldo? Pin
Jeroen De Dauw4-Nov-09 21:06
Jeroen De Dauw4-Nov-09 21:06 
GeneralRe: where's waldo? Pin
David Skelly4-Nov-09 22:43
David Skelly4-Nov-09 22:43 
General4GL horror Pin
Andrew Carrell2-Nov-09 10:09
Andrew Carrell2-Nov-09 10:09 
Here's one that's created in Informix 4GL (which is a horror in itself) on how to validate a from-and-to range to make sure it has no overlaps in the DB:

FUNCTION verify_location()


	DECLARE c_det_cur CURSOR FOR 
		SELECT frerc.from_loc_id, frerc.to_loc_id
		FROM frerc
			WHERE frerc.dc_id = m_i_frerc_rec.dc_id
			  AND frerc.whse_id = m_i_frerc_rec.whse_id
	
	# check if select worked correctly
	IF SQLCA.SQLCODE <> 0
	THEN
		#...
		RETURN TRUE, 0
	END IF

	OPEN c_det_cur 
	IF SQLCA.SQLCODE <> 0
	THEN
		#...
		RETURN TRUE, 0
	END IF

	FETCH c_det_cur INTO m_from_loc, m_to_loc

	IF m_modify = 0 AND m_i_frerc_rec.from_loc_id >= m_from_loc
		AND m_i_frerc_rec.from_loc_id <= m_to_loc 
	THEN
		CALL sh_err_msg("S2096")
		LET m_from = 1
		LET m_modify = 1
	END IF
	
	IF m_modify = 0 AND m_i_frerc_rec.to_loc_id >= m_from_loc
		AND m_i_frerc_rec.to_loc_id <= m_to_loc 
	THEN
		CALL sh_err_msg("S2097")
		LET m_from = 1
		LET m_modify = 1
	END IF
	
	IF m_from_loc >= m_i_frerc_rec.from_loc_id
		AND m_from_loc <= m_i_frerc_rec.to_loc_id
	THEN
		CALL sh_err_msg("S2097")
		LET m_from = 1
		LET m_modify = 1
	END IF
	
	IF m_modify = 0 AND m_to_loc >= m_i_frerc_rec.from_loc_id
		AND m_to_loc <= m_i_frerc_rec.to_loc_id
	THEN
		CALL sh_err_msg("S2096")
		LET m_to = 1
	END IF 	

	IF m_to = 0 AND 
		m_from = 0
	THEN
		WHILE SQLCA.SQLCODE = 0
			FETCH c_det_cur INTO m_from_loc, m_to_loc

			IF m_i_frerc_rec.from_loc_id >= m_from_loc
				AND m_i_frerc_rec.from_loc_id <= m_to_loc 
			THEN
				CALL sh_err_msg("S2096")
				LET m_from = 1
				EXIT WHILE
			END IF

			IF m_i_frerc_rec.to_loc_id >= m_from_loc
				AND m_i_frerc_rec.to_loc_id <= m_to_loc 
			THEN
				CALL sh_err_msg("S2097")
				LET m_from = 1
				EXIT WHILE
			END IF

			IF m_from_loc >= m_i_frerc_rec.from_loc_id
				AND m_from_loc <= m_i_frerc_rec.to_loc_id
			THEN
				CALL sh_err_msg("S2097")
				LET m_to = 1
				EXIT WHILE
			END IF
		
			IF m_to_loc >= m_i_frerc_rec.from_loc_id
				AND m_to_loc <= m_i_frerc_rec.to_loc_id
			THEN
				CALL sh_err_msg("S2096")
				LET m_from = 1
				EXIT WHILE
			END IF
	
		END WHILE
	END IF
	
	LET m_modify = 0

END FUNCTION

GeneralAm I missing Something? Pin
outside cosmic31-Oct-09 22:08
outside cosmic31-Oct-09 22:08 
GeneralRe: Am I missing Something? Pin
OriginalGriff31-Oct-09 22:13
mveOriginalGriff31-Oct-09 22:13 
GeneralRe: Am I missing Something? Pin
outside cosmic31-Oct-09 22:24
outside cosmic31-Oct-09 22:24 
GeneralRe: Am I missing Something? Pin
OriginalGriff31-Oct-09 22:40
mveOriginalGriff31-Oct-09 22:40 
GeneralRe: Am I missing Something? Pin
outside cosmic31-Oct-09 22:54
outside cosmic31-Oct-09 22:54 
GeneralRe: Am I missing Something? Pin
Nagy Vilmos2-Nov-09 4:02
professionalNagy Vilmos2-Nov-09 4:02 
GeneralRe: Am I missing Something? Pin
PIEBALDconsult1-Nov-09 6:02
mvePIEBALDconsult1-Nov-09 6:02 
GeneralRe: Am I missing Something? Pin
Diego.Martinez1-Nov-09 21:53
Diego.Martinez1-Nov-09 21:53 
GeneralRe: Am I missing Something? Pin
Steven Kirk25-Nov-09 8:44
Steven Kirk25-Nov-09 8:44 
GeneralRe: Am I missing Something? Pin
Keith Barrow2-Nov-09 4:15
professionalKeith Barrow2-Nov-09 4:15 
GeneralRe: Am I missing Something? Pin
0x3c02-Nov-09 4:33
0x3c02-Nov-09 4:33 
GeneralRe: Am I missing Something? Pin
Keith Barrow2-Nov-09 4:58
professionalKeith Barrow2-Nov-09 4:58 
GeneralRe: Am I missing Something? Pin
0x3c02-Nov-09 8:21
0x3c02-Nov-09 8:21 
GeneralRe: Am I missing Something? Pin
Keith Barrow2-Nov-09 9:54
professionalKeith Barrow2-Nov-09 9:54 
GeneralRe: Am I missing Something? Pin
PIEBALDconsult2-Nov-09 17:29
mvePIEBALDconsult2-Nov-09 17:29 
GeneralRe: Am I missing Something? Pin
Jorg DD1-Dec-09 22:03
Jorg DD1-Dec-09 22:03 
GeneralA new way to create a DateTime from the year! Pin
sergiogarcianinja30-Oct-09 7:48
sergiogarcianinja30-Oct-09 7:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.