12-29-2025, 10:13 PM
Well, made a couple of alterations so I'll post the new version, this time using the [ code] tags and see what happens.
What's new? Well, all variables are now prefixed with 'menu_' so that I know they are for the menu only. Only variable that's not prefixed is the 'menu' variable that returns which line was picked.
I've also added the option for the menu to 'roll over' when it get's to the top or bottom
And it looks like the [ code][ /code] still show the wrong characters :-(
What's new? Well, all variables are now prefixed with 'menu_' so that I know they are for the menu only. Only variable that's not prefixed is the 'menu' variable that returns which line was picked.
I've also added the option for the menu to 'roll over' when it get's to the top or bottom
Code: (Select All)
'
' My little menu routine
'
' Can be used with up/down arrow keys or mouse
'
' Okay, it could be tidied up quite a lot but it works :-)
'
'
' Altered all menu variables by adding prefix 'menu_'
' Added the roll over option at top and bottom of menu
'
Screen 0
menu_defc1 = 0
menu_defc2 = 7
Color menu_defc1, menu_defc2
Cls
' z$(x) holds the info for the menu1
' Option chosen is returned in the variable 'menu'
' info for menu1
z$(1) = " Seaward SuperNova (including Plus and Elite) "
z$(2) = " Seaward Primetest "
z$(3) = " Metrel BetaPat / OmegaPAT "
z$(4) = " Robin 5500 "
z$(5) = " MetroTest MPAT 60 / Martindale MicroPat "
z$(6) = " Megger 420 "
z$(7) = " KewTech KT74 (via RS-232) "
z$(8) = " Kewtech KT74 (Via USB) "
z$(9) = " Kewtech KT77 (via RS-232) "
z$(10) = " Kewtech KT77 (via USB) "
' menu_pt = number of menu entries
menu_pt = 10
' menu_mr = right most column for mouse to work.
' usualy the length of longest menu entry
menu_mr = 46
' menu colours
' menu_c1 & menu_c2 non highlighted
' menu_c3 & menu_c4 highlighted
menu_c1 = 0
menu_c2 = 7
menu_c3 = 7
menu_c4 = 0
' menu_px & menu_py screen locations for top left of menu
' menu_px row
' menu_py column
menu_px = 4
menu_py = 3
' border on/off
' menu_pb = 1 border on
' menu_pb = 0 border off
menu_pb = 1
' border colour
menu_c5 = 1
' When top/bottom reached do we stop or roll over
' 0 = stop
' 1 = Roll over
menu_over = 1
GoSub Menu
Cls
Locate 2, 2
Print "Option "; menu; " chosen"
End
' ********************* Menu Section Starts Here *******************
Menu:
' draw the border if needed
If menu_pb = 1 Then
Color menu_c5, menu_c2
menu_pb = 0
Locate menu_py, menu_px
Print "Õ";
For i = 1 To menu_mr
Print "Í";
Next
Print "¸"
For i = 1 To menu_pt
Locate menu_py + i, menu_px
Print "³"; String$(menu_mr, 32); "³"
Next
Locate menu_py + menu_pt + 1, menu_px
Print "Ô";
For i = 1 To menu_mr
Print "Í";
Next
Print "¾"
menu_py = menu_py + 1
menu_px = menu_px + 1
End If
' Border finished
' Lets display the menu
menu_z1 = 0
reprint:
If menu_over = 0 Then
If menu_z1 <= 0 Then menu_z1 = 0
If menu_z1 >= (menu_pt - 1) Then menu_z1 = menu_pt - 1
Else
If menu_z1 <= -1 Then menu_z1 = menu_pt - 1 'menu_z1 = 0
If menu_z1 >= menu_pt Then menu_z1 = 0 'menu_z1 = menu_pt - 1
End If
Color menu_c1, menu_c2
For i = 1 To menu_pt
Locate menu_py + (i - 1), menu_px
Print z$(i)
Next
Locate menu_py + menu_z1, menu_px
Color menu_c3, menu_c4
Print z$(menu_z1 + 1)
' do the mouse and cursor key inputs
mousein:
Do
Do While _MouseInput ' Check the mouse status
menu_mx = _MouseX
menu_my = _MouseY
menu_mb1 = _MouseButton(1)
' mb2 = _MOUSEBUTTON(2)
' mw = _MOUSEWHEEL
If menu_mb1 = -1 Then
menu = menu_z1 + 1
Color menu_defc1, menu_defc2
Return
End If
If menu_omy <> menu_my Then
If menu_mx >= menu_px And menu_mx < (menu_mr + menu_px) And menu_my >= menu_py And menu_my < menu_pt + menu_py Then
menu_z1 = menu_my - menu_py
menu_omy = menu_my
GoTo reprint
End If
End If
Loop
menu_x$ = InKey$
Loop Until menu_x$ <> ""
menu_lx = Asc(menu_x$)
' Down Arrow
If menu_x$ = Chr$(0) + Chr$(80) Then
menu_z1 = menu_z1 + 1
GoTo reprint
End If
' Up Arrow
If menu_x$ = Chr$(0) + Chr$(72) Then
menu_z1 = menu_z1 - 1
GoTo reprint
End If
' Enter key
If menu_x$ = Chr$(13) Then
menu = menu_z1 + 1
Color menu_defc1, menu_defc2
Return
End If
GoTo mousein
Oh look. A sig line :-)

