Drawing function query

BlitzPlus Forums/BlitzPlus Beginners Area/Drawing function query

In this particular case there was so much wrong with that function that fixing the code would've been less work than writing an essay on all the details.

Function Dibujo(guibank)
	canvas=PeekInt(guibank,4)
	File=PeekInt(guibank,8)   <- not needed
	draw=PeekInt(guibank,12)
	canvasx=PeekInt(guibank,16) <- not needed
	canvasy=PeekInt(guibank,20) <- not needed
		SetBuffer CanvasBuffer(canvas) <- wrong place, tad hard to explain now, but you opened a drawingbuffer while you weren't sure you'd be closing it (flipcanvas was in an IF statement) and in B+ you should *never* leave a canvasbuffer open upon quit.
			Select EventID()
				Case $203
					If MouseX>canvasx  <- not needed
						If MouseY>canvasy  <- not needed
							If ButtonState(draw)=True Then
								Plot MouseX,MouseY  <- had to be eventx() and eventy()
									FlipCanvas canvas
							EndIf
						EndIf  <- not needed
					EndIf  <- not needed
			End Select
End Function 


So, as you see, there was really a lot to fix in there. Most of it could just be wiped away. In this case it was the easiest way to just present a finished function rather than a whole story related to each line which is now trailed by a <-

As was said before: it's just a tiny function that does nothing special or highly advanced, there enough to find out yourself. It's the functionality, not the implementation.