Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to create a simple menu
#3
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:
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 Sub

Also 
Code: (Select All)
    Dim mrtxt$(1 To 4)
    mrtxt$(1) = "Hello"
    mrtxt$(2) = "Goodbye"
    mrtxt$(3) = "Now"
    mrtxt$(4) = "Get Out"
 Can be moved to main and done once and for all time with DIm Shared mrtxt$()
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Trying to create a simple menu - by CMR - 05-12-2025, 08:34 PM
RE: Trying to create a simple menu - by Pete - 05-12-2025, 08:48 PM
RE: Trying to create a simple menu - by SMcNeill - 05-12-2025, 09:11 PM
RE: Trying to create a simple menu - by CMR - 05-13-2025, 01:47 AM
RE: Trying to create a simple menu - by bplus - 05-12-2025, 09:05 PM
RE: Trying to create a simple menu - by Pete - 05-12-2025, 09:23 PM
RE: Trying to create a simple menu - by CMR - 05-13-2025, 03:15 AM
RE: Trying to create a simple menu - by CMR - 05-13-2025, 07:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Universal Menu Concept Pete 3 375 01-05-2026, 07:31 PM
Last Post: Pete
  Nice simple, I hope, question Mad Axeman 4 343 12-20-2025, 09:28 PM
Last Post: SMcNeill
  Is there a menu function? Mad Axeman 17 1,041 12-17-2025, 04:43 AM
Last Post: SMcNeill
Photo from png tile, create symmetrical screen image hsiangch_ong 11 941 08-23-2025, 01:23 AM
Last Post: bplus
  Simple Addition gone wrong Dimster 13 1,435 08-22-2025, 09:00 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)