Posted: Mon Nov 22, 2004 9:18 am Post subject: stopping repeated use of the return key
This is a part of my battleship code. i need to make sure that if the user presses enter without inputing a value the cursor remains in the same place.
code:
loop
put "What is the x value?"
get input
loop
exit when strintok (input)
drawfillbox (0, 320, maxx, maxy, 0)
locate (1, 1)
put "Bad input(number between 1 and 10)"
get input
end loop
gx := strint (input)
exit when gx >= 1 and gx <= 10
drawfillbox (0, 320, maxx, maxy, 0)
locate (1, 1)
end loop
Sponsor Sponsor
Delos
Posted: Mon Nov 22, 2004 9:48 am Post subject: (No subject)
Use getch().
You'll need to put the input value onto the screen after it has been getch()ed as that routine does not return the inputted value to the screen.
Also stick w/ your idea of locate()s. They'll do well w/ the input too.
gigaman
Posted: Tue Nov 23, 2004 9:27 am Post subject: (No subject)
the problem with using getch is that it only takes 1 input character. i need it to take 1 or 2 characters as input because i need between 1 and 10
Delos
Posted: Tue Nov 23, 2004 11:41 am Post subject: (No subject)
Well...come on! You're in compsci! If you need a series of 10 inputs, and you have a reliable command that only takes 1 input...