cls
`Menu Array - (menu item,submenu item)
dim MenuOptions$(5,4)
`how many values to read from the menu
dim MenOptCount(5)
gosub setupmendat
sync on
 
open=0
repeat
  cls
  Center Text 320,0,"Menu Item Selected: "+MenuOptions$(Open,0)
  if open=0
    for y=1 to 5
      set cursor 10,y*15 : print MenuOptions$(y,0)
    next y
    if mouseclick()=1
      if mousex()>10 and mousex()<100
        for y=1 to 5
          if mousey()>(y*15) and mousey()<((y+1)*15) then open=y
        next y
      endif
      repeat
      until mouseclick()=0
    endif
  else
    for y=1 to open
      set cursor 10,y*15 : print MenuOptions$(y,0)
    next y
    for y=open+1 to 5
      set cursor 10,(y*15)+(15*MenOptCount(open)) : print MenuOptions$(y,0)
    next y
    for y=1 to MenOptCount(open)
      set cursor 20,(open+y)*15 : print "- "+MenuOptions$(open,y)
    next y
 
 
    if mouseclick()=1
      if mousex()>10 and mousex()<100
        for y=1 to open
          if mousey()>(y*15) and mousey()<((y+1)*15)
            if open=y
              open=0
            else
              open=y
            endif
          endif
        next y
        for y=open+1 to 5
          if mousey()>(15*(y+MenOptCount(open))) and mousey()<(15*(y+MenOptCount(open)+1)) Then open=y
        next y
      endif
      repeat
      until mouseclick()=0
    endif
 
 
  endif
 
  remstart
  if open=2 then contdat#=2
  if open=3 then contdat#=3
  if open=5 then end
 
  if spacekey()=1 then open=0
  remend
  sync
until contdat#>110
cls
if contdat#=2 then print "You have selected the Load Game option"
if contdat#=3 then print "You have selected the Help/Instructions option"
 
suspend for key
end
 
setupmendat:
  `1 - new game:
  MenOptCount(1)=4
  MenuOptions$(1,0)="New Game"
  MenuOptions$(1,1)="Beginner"
  MenuOptions$(1,2)="Intermediate"
  MenuOptions$(1,3)="Hard"
  MenuOptions$(1,4)="Expert"
  `2 - load game:
  MenOptCount(2)=0
  MenuOptions$(2,0)="Load Game"
  `3 - help:
  MenOptCount(3)=0
  MenuOptions$(3,0)="Help/Instructions"
  `4 - settings:
  MenOptCount(4)=3
  MenuOptions$(4,0)="Settings"
  MenuOptions$(4,1)="Audio"
  MenuOptions$(4,2)="Visual"
  MenuOptions$(4,3)="Controls"
  `5 - load game:
  MenOptCount(5)=0
  MenuOptions$(5,0)="Exit"
return