Computer Science Canada

Simple 'get' command problem

Author:  sofa_king [ Thu Jun 10, 2004 7:10 pm ]
Post subject:  Simple 'get' command problem

Ok i have this problem that i want to avoid for my game. ill give u a sample code first:

code:

var number:int

put "What number will you choose:"..
get number


yea simple code right? well teh problem im trying to avoid is preventing it from going to the next line. Umm what i mean is that if the user presses enter by accident with no answer, it will get the number at teh next line right? i dont want it to go to the next line. would be nice if i also knew how to make sure the number/key the user enters doesnt go beyond one character.

Also does anyone noe how to clear one line or a string only but keep the rest of the text?

Author:  Paul [ Thu Jun 10, 2004 7:32 pm ]
Post subject: 

What? can u explain more clearly? If you mean making sure the string doesn't go beyond one character, then u use getch on a string(1) variable.

Author:  Delos [ Thu Jun 10, 2004 7:42 pm ]
Post subject: 

I'm guessing something to the effect of Paul's words...

In a loop...getch a character at a time...then display that character at a located position...But...only display it if it within a certain range of values (use ord/chr to find the necassary #'s)...

Author:  sofa_king [ Thu Jun 10, 2004 7:51 pm ]
Post subject: 

umm ok sorry for the clarity.

Ok so on the output of that sample code, its waiting for the user to enter a number right? If the user presses enter without typing anything, the flashing cursor will go on to the next line and wait for the user to enter it on the next line.

I dont want the 'get' to go on to the next line.




if ur still confused, check out my proggie, and when a question is aksed, press enter without anything typed(ull see that the game format is messed up after that). Dont use the audience lifeline aswell.


EDIT: Delos, could u plz give a sample code, im rather confused. Also, its supposed to be an integer value im inputting.

Author:  TrAnCeIn4LiFe [ Sun Jun 13, 2004 9:08 am ]
Post subject: 

well do it with if statment something like

code:
var number : int
var number2 : int

if number = "" then
    put "What number will you choose:" ..
    get number
else
    put "What number will you choose:" ..
    get number2
end if



: