a curious buffer error

BlitzPlus Forums/BlitzPlus Programming/a curious buffer error

julianbury(Posted 2010) [#1]
Dear community,
Can anybody tell me why I get a buffer error from this code?

Dim result(32)
Global target$="witchcraft"
Global wordsize=10
Global xdesktop=GraphicsWidth()
Global ydesktop=GraphicsHeight()
Global xframe=512
Global yframe=600
Global xposition=(xdesktop/2)-(xframe/2)
Global yposition=(ydesktop/2)-(yframe/2)

Global window=CreateWindow("WordsGame",xposition,yposition,xframe,yframe,0,1)

Global editorfont=LoadFont("courier new",30,0,0,0)
Global resultfont=LoadFont("courier new",20,0,0,0)

Global editor=CreateTextField(100,16,300,32,window)
SetGadgetFont editor,editorfont
SetGadgetText editor,"----------"


For i=0 To 15
result(i)=CreateTextField(32,(64+i*26),200,22,window)
SetGadgetFont result(i),resultfont
SetGadgetText result(i),"------------"
Next
For i=16 To 31
result(i)=CreateTextField(270,(64+(i-16)*26),200,22,window)
SetGadgetFont result(i),resultfont
SetGadgetText result(i),"------------"
Next

; this is where the error occurs "Invalid Blitz 2D Buffer handle"
SetFont editorfont
Global editorwidth=StringWidth(target$)
SetGadgetShape editor,100,16,editorwidth,32


SetFont resultfont
resultwidth=StringWidth(target$)
SetGadgetShape result(1),100,16,resultwidth,32


Repeat
If WaitEvent()=$803 End
If KeyDown(1) End
Forever


Floyd(Posted 2010) [#2]
You need a Graphics command somewhere.


julianbury(Posted 2010) [#3]
Hi Floyd :-)

Since it is a text-only game, I was hoping to do it all in gadgets.

Doing it all in graphics presents another set of problems such as not being able to detect vital key_presses.

So, it seems B+ provides only parts of each mode - graphics and gadgets.

:-/

like so much else in life.

Ah, well ...


Matty(Posted 2010) [#4]
replace this

Global xdesktop=GraphicsWidth()
Global ydesktop=GraphicsHeight()


with this

Global xdesktop=gadgetwidth(Desktop())
Global ydesktop=gadgetheight(Desktop())


julianbury(Posted 2010) [#5]
Hi Matty,

Thanks for the suggestion :-)

I can't try it right now as I am about to install Windows7.

If my computer survives that, I'll get right on it and tell you if it works :-)


(^_^)