Why does this fail to work?

Blitz3D Forums/Blitz3D Programming/Why does this fail to work?

bradford6(Posted 2005) [#1]
hit the up arrow.


Global foo:Int


Repeat
	
	key(KEY_UP,foo,5)
	Print foo


Until KeyDown(KEY_ESCAPE)




Function key(keyconst,variable,amount)
	If KeyDown(keyconst) = 1
		variable = variable + amount
	EndIf
	
End Function




Perturbatio(Posted 2005) [#2]
where are you getting KEY_UP and KEY_ESCAPE from?

if you aren't defining them, they will be set to 0.

I put something in the code archives a while ago to help with this


WolRon(Posted 2005) [#3]
It's BlitzMax code, and he posted in the wrong forum...


Perturbatio(Posted 2005) [#4]
ahhh... so it is.

in that case:
Global foo:Int
Graphics 640,480,0,0

Repeat
	Cls
	key(KEY_UP,foo,5)
	DrawText foo, 10,10

Flip
Until KeyDown(KEY_ESCAPE)




Function key(keyconst,variable Var,amount)
	If KeyDown(keyconst) = 1
		variable = variable + amount
	EndIf
	
End Function