OH no! i'm making a dropdown menu!!

Blitz3D Forums/Blitz3D Beginners Area/OH no! i'm making a dropdown menu!!

Hmm, i took some time to mess with it, it looks like this is the right direction, but for the life of me i cant figure out whats wrong with this:

Global InitDD,drawdrop,scrolly,shown
Global CursorX, CursorY, CursorHit

;-----------------------------------------------------------------
;                       CreateDropDown()
;-----------------------------------------------------------------


Type dd
Field drawdrop
Field scrolly
Field shown
Field InitDD
End Type

Function CreateDropDown$(x,y,words$,number)

If InitDD>2
b.dd = New dd
b\drawdrop=False
b\scrolly=x+20
b\shown=x
InitDD=InitDD+1
End If



;If you click on the button, dropdown=True
If RectsOverlap(x+75,y,25,20,CursorX,CursorY,10,10) And CursorHit
  If b\drawdrop=False
     b\drawdrop=True
Else
   b\drawdrop=False
  End If
End If

If b\drawdrop=True
Rect x,y,100,200,0

;For...Each ... should get the name of all the objects.
i=0
For checklist.list = Each list

If checklist\listnumber=number
i=i+1

;Made this For i...2 loop so the Text can loop itself...
Viewport x,y+20,100,180
   Text x,b\shown+(i*20),checklist\name
Viewport 0,0,GraphicsWidth(),GraphicsHeight()

;If you click on one of the names it will put it up top.
    If RectsOverlap(x,shown+(i*20),75,20,CursorX,CursorY,10,10) And MouseDown(1)
        words$=checklist\name
        b\drawdrop=False
        b\shown=10+20
        b\scrolly=10
     End If


End If
Next
Rect x+75,y+20,25,180,False
If i>9 
   Rect x+75,b\scrolly,25,20,True
  If RectsOverlap(x+75,y+20,25,180,CursorX,CursorY,10,10) And MouseDown(1)
     b\scrolly=CursorY
  End If
If b\scrolly<y+20 b\scrolly=y+20
If b\scrolly>y+180 b\scrolly=y+180

;The more things in the Text the faster it scrolls To compensate..
ScrollbarPos = ScrollY - y-20
ScrollbarMax = y+180- y-20
ListSize = (i - 9) * 20 
b\shown = 10 - (scrollbarpos * listsize / scrollbarmax)


End If

End If



;Draws the Button to dropdown and the main box, and draws the words you picked..
Rect x,y,100,20,0
Rect x+75,y,25,20,0
Text x,y,words


Return words$

End Function

;-----------------------------------
;            main prog
;-----------------------------------

Graphics 300,500,16,2

SetBuffer BackBuffer()

Type list
   Field name$
   Field listnumber
End Type

For i=1 To 200

DD1.list = New list
DD1\name="bah"+i
DD1\listnumber=1

Next

For i=1 To 400

DD2.list = New list
DD2\listnumber=2
DD2\name="meh"+i

Next





While Not KeyHit(1)
Cls

CursorX = MouseX()
CursorY = MouseY()
CursorHit = MouseHit(1)

blah$=CreateDropDown$(10,10,blah$,2)
blah2$=CreateDropDown$(150,10,blah2$,1)



Delay 5
Flip
Wend 




i get a MAV error, thats a first.. but thats the right direction?

Any ideas?