Here is simplest thing to show an action when getout enter, I also removed the parameter to menu sub and just shared state with main and all routines. You might now use state in select case to run the routine on each menu item:
Also
Can be moved to main and done once and for all time with DIm Shared mrtxt$()
Code: (Select All)
''Create a menu with selectable options
Option _Explicit
$Color:0
''main program area
Dim Shared state&: state& = 1
Do
_Limit (60)
PopUpMenu
Loop Until state& = 0
Sleep
End
''----------------------Subroutines--------------------------
Sub PopUpMenu
''routine for popup menu - active subsystems should check for their own input
Dim mrtxt$(1 To 4)
mrtxt$(1) = "Hello"
mrtxt$(2) = "Goodbye"
mrtxt$(3) = "Now"
mrtxt$(4) = "Get Out"
Static msel&
''Check for input
If _KeyDown(18432) Then ''up
msel& = msel& - 1
End If
If _KeyDown(20480) Then ''down
msel& = msel& + 1
End If
''wrap menu cursor
If msel& < LBound(mrtxt$) Then msel& = UBound(mrtxt$)
If msel& > UBound(mrtxt$) Then msel& = LBound(mrtxt$)
If _KeyDown(13) Then ''Enter
''Exit the program when enter is pressed on Get Out
If msel& = 4 Then state& = 0: End
End If
''Draw the menu to the screen
DrawMenuBox 3, 4, mrtxt$(), msel&
Sleep .001
End Sub ''PopUpMenu
Sub DrawMenuBox (row&, col&, mtxt$(), hl&)
''Draw a menu Box on the screen
Dim tw&, th&
''Get the number of lines of text to draw and determine the longest
th& = UBound(mtxt$) - LBound(mtxt$) + 1
Dim i
For i = LBound(mtxt$) To UBound(mtxt$)
If Len(mtxt$(i)) > tw& Then tw& = Len(mtxt$(i))
Next
''Generate the text Box
Color Black, White
''top row
Locate row&, col&
Print "?" + String$(tw&, "?") + "?"
''Print txt rows
For i = 1 To th&
Locate row& + i, col&
Print "?" + Space$(tw&) + "?"
Next
''bottom row
Locate row& + th& + 1, col&
Print "?" + String$(tw&, "?") + "?"
''Print text onto box
For i = 1 To th&
If i = hl& Then
Color White, Black
Locate row& + i, col& + 1
Print mtxt$(i) + Space$(tw& - Len(mtxt$(i)))
Color Black, White
Else
Locate row& + i, col& + 1
Print mtxt$(i) + Space$(tw& - Len(mtxt$(i)))
End If
Next
End SubAlso
Code: (Select All)
Dim mrtxt$(1 To 4)
mrtxt$(1) = "Hello"
mrtxt$(2) = "Goodbye"
mrtxt$(3) = "Now"
mrtxt$(4) = "Get Out"
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

