Qbasicnews.com

Full Version: Menu help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello... got a problem with a menu. It is working but not as i want:

Code:
CLS : SCREEN 9

cursorRow = 8
cursorCol = 33
cursorPosition = 1

LOCATE 8, 35
PRINT "New"

LOCATE 10, 35
PRINT "Load"

LOCATE 12, 35
PRINT "Exit"

DO

DO
key$ = INKEY$
LOOP UNTIL key$ <> ""

LOCATE cursorRow, cursorCol
PRINT " "

IF key$ = CHR$(0) + CHR$(72) THEN cursorRow = cursorRow - 2
IF key$ = CHR$(0) + CHR$(80) THEN cursorRow = cursorRow + 2

IF cursorRow = 8 THEN cursorPosition = 1
IF cursorRow = 10 THEN cursorPosition = 2
IF cursorRow = 12 THEN cursorPosition = 3

IF ((cursorPosition = 1) AND (key$ = CHR$(0) + CHR$(72))) THEN cursorRow = 12
IF ((cursorPosition = 3) AND (key$ = CHR$(0) + CHR$(80))) THEN cursorRow = 8

LOCATE cursorRow, cursorCol
PRINT ">"

LOOP

Now, i want so that if the cursor is on "New" and you press the upp-arrow the cursor goes to the "Exit" choice and the same thing when the cursor are at the "Exit" choice but it wont it just keep going up/down, please help.

Oh, and sorry for my bad English.
i do belive it may be that simple!
try it my friend! and let me know!

Code:
CLS : SCREEN 9

cursorRow = 8
cursorCol = 33
cursorPosition = 1

LOCATE 8, 35
PRINT "New"

LOCATE 10, 35
PRINT "Load"

LOCATE 12, 35
PRINT "Exit"

DO

DO
key$ = INKEY$
LOOP UNTIL key$ <> ""

LOCATE cursorRow, cursorCol
PRINT " "

IF key$ = CHR$(0) + CHR$(72) THEN cursorRow = cursorRow - 2
IF key$ = CHR$(0) + CHR$(80) THEN cursorRow = cursorRow + 2


'Weed out your imposabilitys first

IF cursorRow=6 THEN cursorRow=12  
IF cursorRow=14 THEN cursorRow=8

'Then make your declarations

IF cursorRow = 8 THEN cursorPosition = 1
IF cursorRow = 10 THEN cursorPosition = 2
IF cursorRow = 12 THEN cursorPosition = 3

LOCATE cursorRow, cursorCol
PRINT ">"

LOOP
Yes, it work, thank you so much Smile
Another problem now... how do i make so that if you have the cursor on "Exit" and press enter the program end? I tried with SELECT CASE but it did'nt work Sad
Code:
IF cursorRow = 8 THEN cursorPosition = 1
IF cursorRow = 10 THEN cursorPosition = 2
IF cursorRow = 12 THEN cursorPosition = 3

if key$ = chr$(32) then
if cursorPosition = 1 then
  '[ your manu one code or sub]
end if
if cursorPosition = 2 then
  '[ your manu two code or sub]
end if
if cursorPosition = 3 then
  '[ your manu three code or sub]
  'or}
  SYSTEM  '<--- This ends entire program
end if
end if

LOCATE cursorRow, cursorCol
PRINT ">"

LOOP

This should work!
i know you can use case, while-wend,and if..then..else
i like using if..then..else for every thing i do!

luck to you
Code:
CLS : SCREEN 9

cursorRow = 8
cursorCol = 33
cursorPosition = 1

LOCATE 8, 35
PRINT "New"

LOCATE 10, 35
PRINT "Load"

LOCATE 12, 35
PRINT "Exit"

LOCATE cursorRow, cursorCol
PRINT ">"  '<----- That put's the cursor in the first position

DO

DO
key$ = INKEY$
LOOP UNTIL key$ <> ""

LOCATE cursorRow, cursorCol
PRINT " "

IF key$ = CHR$(0) + CHR$(72) THEN cursorRow = cursorRow - 2
IF key$ = CHR$(0) + CHR$(80) THEN cursorRow = cursorRow + 2


'Weed out your imposabilitys first

IF cursorRow=6 THEN cursorRow=12  
IF cursorRow=14 THEN cursorRow=8

'Then make your declarations

IF cursorRow = 8 THEN cursorPosition = 1
IF cursorRow = 10 THEN cursorPosition = 2
IF cursorRow = 12 THEN cursorPosition = 3

LOCATE cursorRow, cursorCol
PRINT ">"

if cursorPosition = 3 and key$ = chr$(13) then exit do
'^
' |---- That allow's user to press enter on exit to close program.

LOOP

Hope this helps you out.