Code archives/Miscellaneous/Debug Onscreen Text thingy

This code has been declared by its author to be Public Domain code.

Download source code

Debug Onscreen Text thingy by Rob Farley2005
OK,

You know how you want to build up debug text on screen but you're in functions and stuff and you can't display on the fly because it won't work with the flip or you're going to do a renderworld first etc etc... Anyway... If you're like me you end up filling a bunch of temp variables to display just before the flip...

Anyway... I came up with this little function... And it's dead handy.

Usage:
Declare a global string
Global DebugTxT$=""
Then as you run through your code add stuff to debug text
DebugTxt = DebugTxt + "FPS:" + fps + "|"
Note the barre (|) at the end. This is your return character.

So as you go through your functions
DebugTxt = DebugTxt + "Alien ID:" + a\id + "|"
DebugTxt = DebugTxt + "    Health:" + a\health + "|"
etc
etc

Then just before your flip
updateworld
Renderworld
debugtext(debugtxt)
flip
until keyhit(1)
And you end up with all your text down the side of the screen... great eh!
Function debugtext(txt$)
	If Right(txt,1) <> "|" Then txt = txt + "|"
	ty=0
	Repeat
		tx=Instr(txt,"|")
		If tx>0
			Text 0,ty,Left(txt,tx-1)
			txt = Right(txt,Len(txt)-tx)
			ty=ty + 10
		EndIf
	Until tx = 0
	debugtxt = ""
End Function

Comments

Vertigo2007
I am so surprised no one commented on this little piece... This thing comes in freaking handy. Sure beats logging to a file. Thanks.


christian2232008
Cool! realtime debugging, pretty cool, just what i was looking for, thanks a million.


Code Archives Forum