Qbasicnews.com

Full Version: Unique input style....
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, I want to make an unique input style where the user has a few seconds to make an input in a trivia sort of program before one of the choices get deleted and user lose a mark for that. I almost suceed in doing it but after nearly 2 hours of debugging, it doesn't work the way I want.

Here is the part of my code that I can't figure out how to do it:
Code:
PRINT "Trivia Question Number 1"
PRINT "Each choice = 4 marks. "
PRINT "Most graphic editing professionals use which of the following"
PRINT "programs to edit their work?"

fchoice$(1) = "A. Adobe Photoshop"
fchoice$(2) = "B. Jasc Paintshop Pro"
fchoice$(3) = "C. Microsoft Paint"
fchoice$(4) = "D. Adobe Photoshop Element"

FOR K = 1 TO 4
        PRINT fchoice$(K)   'Where I list my choices
        
NEXT K
SLEEP 5 'Give the user 5 secs to answer

inputkey$ = INKEY$
IF inputkey$ <> "" THEN
        INPUT "Please enter your choice"; choice$
        IF choice$ = "a" then
               PRINT whatever I want
'If the user press any key during the 5 seconds, the INPUT dialogue will pop up to ask user for choice selection.

ELSEIF inputkey$ = "" THEN
        FOR K = 1 TO 3
                PRINT fchoice$(K)
        NEXT K

'If the user doesn't press any key during the 5 seconds, one of the choices will be deleted and the user loses a mark but has 2 more choice to answer before he gets a zero.

      
END IF

That's what it suppose to work like. The problem is that it doesn't work at all no matter what I tried. I get the same results if I press any keys or if I don't press any at all. Anyone know what's wrong with it? Thanks alot.
Smile [/i]

Anonymous

Code:
screen 13

dim fchoice$(5)

PRINT "Trivia Question Number 1"
PRINT "Each choice = 4 marks. "
PRINT "Most graphic editing professionals use which of the following"
PRINT "programs to edit their work?"

fchoice$(1) = "A. Adobe Photoshop"
fchoice$(2) = "B. Jasc Paintshop Pro"
fchoice$(3) = "C. Microsoft Paint"
fchoice$(4) = "D. Adobe Photoshop Element"

FOR K = 1 TO 4
        PRINT fchoice$(K)   'Where I list my choices
      
NEXT K

    mark# = timer

do
    inputkey$ = inkey$
    if timer - mark# >= 5 then missed% = -1
    locate 13: ? int(6 - (timer - mark#)); " seconds left!!"

loop until inputkey$ <> "" or missed% = -1
     'Give the user 5 secs to answer

if missed% <> -1 then
    
    
    if ucase$(inputkey$) = "A" then
        
        ? "YOURE THE WEINER":while inkey$ = "":wend
    else
        ? "WRONG HAHAHAHA YOU SUCK!!!":sleep
        
    end if
    
else
    
    ?"OUT OF TIME SUCKA!!! YOU LOSE!!!":sleep
    
end if

hope this helps
Thank you very much. This is just what I looked for. Thank you again.