Hi,
I'm in the process of converting a sort of grid text-mode menu system, to one with a single row that will scroll & display more items than the width of the screen will fit.
The menu array is working fine. This is MenuItem().
But the array for the messages associated with each menu item, is a problem. This array is called MenuMessage(), and is defined the same way as MenuItem().
I'm running this in the QB64 ide right now, but will also test it in the 4.5 ide later.
The error is
Illegal string-number conversion on line 37
The line 37 in question is
MenuMessage(1) = "Message for Choice 1"
Is it possible that I'm running up against the limit of the name of an array? 'MenuMessage' is 11 characters.
The full code is here
'horzmenu.bas, originally menucol.bas by Ray Thomas January 2002
Const MAXIMUMITEMLENGTH
= 10
Dim MenuItem
(12) As String * 25 'Define the menu item array Dim MenuMessages
(12) As String * 50 'Define the menu message array Dim XMenuPosn
As Integer 'Controls the menu item X positions Dim YMenuPosn
As Integer 'Controls the menu item Y positions
Dim NumberOfColumns
As Integer 'Number of menu items per line Dim FullItemNameRow
As Integer 'Row where the full name of the item is displayed Dim MessageRow
'Row where a message corresponding to the Menu Item is displayed
MenuItem(1) = "Choice 1"
MenuItem(2) = "Choice 2"
MenuItem(3) = "Choice 3"
MenuItem(4) = "Choice 4"
MenuItem(5) = "Longer Choice 5"
MenuItem(6) = "Choice 6"
MenuItem(7) = "Choice 7"
MenuItem(8) = "Choice 8"
MenuItem(9) = "Choice 9"
MenuItem(10) = "Another Longer Choice 10"
MenuItem(11) = "Choice 11"
MenuItem(12) = "Choice 12"
MenuMessage(1) = "Message for Choice 1"
MenuMessage(2) = "Message for Choice 2"
MenuMessage(3) = "Message for Choice 3"
MenuMessage(4) = "Message for Choice 4"
MenuMessage(5) = "Message for Longer Choice 5"
MenuMessage(6) = "Message for Choice 6"
MenuMessage(7) = "Message for Choice 7"
MenuMessage(8) = "Message for Choice 8"
MenuMessage(9) = "Message for Choice 9"
MenuMessage(10) = "Message for Another Longer Choice 10"
MenuMessage(11) = "Message for Choice 11"
MenuMessage(12) = "Message for Choice 12"
ChooseItem = 1 'Starting point of highlighted menu item
XMenuPosn = 1 'X starting point of menu
YMenuPosn = 1 'Y starting point of menu
NumberOfColumns = 12 'Number of columns in the menu
FullItemNameRow = 4
MessageRow = 5
'*** get cursor key movements and redraw menu ***
'Check for Esc key
DrawMenu:
'Draw the menu
CurrentXMenuPosition
= Pos(0)
Locate CurrentYMenuPosition
, CurrentXMenuPosition
'/*
' Locate FullItemNameRow, 1
' Print Space$(50)
' Locate FullItemNameRow, 1
' Print MenuItem$(Count)
' Locate CurrentYMenuPosition, CurrentXMenuPosition
'*/
MoveUp:
If ChooseItem
<= NumberOfColumns
Then ChooseItem
= UBound(MenuItem$
) - (MenuItem
Mod NumberOfColumns
) ChooseItem = ChooseItem - NumberOfColumns
MoveDown:
ChooseItem
= ChooseItem
Mod MenuLine
ChooseItem = ChooseItem + MenuLine
If ChooseItem
= 0 Then ChooseItem
= MenuLine
Moveleft:
ChooseItem = ChooseItem - 1
MoveRight:
ChooseItem = ChooseItem + 1
TopCol:
ChooseItem
= ChooseItem
Mod MenuLine
If ChooseItem
= 0 Then ChooseItem
= MenuLine
BottomCol:
ChooseItem
= UBound(MenuItem$
) - (MenuLine
- (ChooseItem
Mod MenuLine
))If MenuLine
- (ChooseItem
Mod MenuLine
) = MenuLine
Then ChooseItem
= UBound(MenuItem$
)