Page 1 of 1

Console quiz like program problem

Posted: Tue Aug 23, 2005 12:14 am
by BOOGIEMAN
I want to make a something like a quiz program, but I don't know how to avoid question repetition in console. This is example code:

Code: Select all

If  OpenConsole()
    somenumber = 50
    
    onestartshere:
    ClearConsole()
    Print("Question ONE is blah blah "+Str(somenumber)+": ")
    qqone = Int(Val(Input()))
    If qqone < 1 Or qqone > 10 : Goto onestartshere : EndIf
        
    twostartshere:
    PrintN("")
    Print("Question TWO is again blah "+Str(somenumber)+": ")
    qqtwo = Int(Val(Input()))
    If qqtwo < 5 Or qqtwo > 15 : Goto twostartshere : EndIf
    
    threestartshere:
    PrintN("")
    Print("Question THREE is some blah "+Str(somenumber)+": ")
    qqthree = Int(Val(Input()))
    If qqthree < 5 Or qqthree > 15 : Goto threestartshere : EndIf
    
    PrintN("")
    Print("Press ENTER to continue")
    Input()
    Goto onestartshere
    CloseConsole()
EndIf
End
and this is how I want it to look, whatever number I input (out of specified range)

Image

Is there a command like clearconsole(), but to clear and repeat last question only (leaving all preavious questions untouched)?
Of course, my quiz will have much more than three questions so I need to solve this first

Posted: Tue Aug 23, 2005 1:16 am
by Dare2
Would something like:

Code: Select all

ConsoleLocate(LastX,LastY)
Print(Space(80))
ConsoleLocate(LastX,LastY)
Print("Q")
do it? But you have to keep track of the line positioning.

Posted: Tue Aug 23, 2005 12:14 pm
by BOOGIEMAN
So, you say there is no easy way for solving my problem ? Well, nevermind then, thx

Posted: Tue Aug 23, 2005 2:43 pm
by thefool
1 way would to store all previous lines in a buffer / string and then reprint them before next question..

Posted: Wed Aug 24, 2005 5:44 pm
by BOOGIEMAN
Well I tried that first, but because of "Str(somenumber)" I can't store that in the string

Posted: Wed Aug 24, 2005 6:02 pm
by Trond

Code: Select all

If OpenConsole() = 0
  End
EndIf

ClearConsole()
somenumber = 50 
q = 0

Procedure Wrong()
  Shared q
  ConsoleLocate(0, q)
  Print(Space(80))
  ConsoleLocate(0, q)
EndProcedure

Repeat
  Wrong()
  Print("Question ONE is blah blah "+Str(somenumber)+": ") 
  answ = Val(Input())
Until (answ < 1 Or answ > 10)-1

PrintN("") : q + 1
Repeat
  Wrong()
  Print("Question TWO is again blah "+Str(somenumber)+": ") 
  answ = Val(Input())
Until (answ < 5 Or answ > 15)-1

PrintN("") : q + 1
Repeat
  Wrong()
  Print("Question THREE is some blah "+Str(somenumber)+": ")
  answ = Val(Input())
Until (answ < 5 Or answ > 15)-1

PrintN("")
Print("Press ENTER to continue")
Input()

Posted: Wed Aug 24, 2005 8:03 pm
by netmaestro
ClearConsole() is all I can find.

Posted: Wed Aug 24, 2005 8:16 pm
by okasvi
http://www.purearea.net/pb/download/use ... ary_v1.zip

take a look in that incase there is what you need. i haven ever needed anything more than basics in PB so i dont know... hope this helps :)

Posted: Thu Aug 25, 2005 1:01 pm
by BOOGIEMAN
OMG Trond, your code works perfectly ! :D Thank you, thanks all

By the way, I don't understand why when I remove -1 from

Code: Select all

Until (answ < 1 Or answ > 10)-1
or I change it to -2 (for example) code doesn't work properly ?