Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple 'get' command problem
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sofa_king




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Thu Jun 10, 2004 7:32 pm   Post subject: (No 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.
Delos




PostPosted: Thu Jun 10, 2004 7:42 pm   Post subject: (No 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)...
sofa_king




PostPosted: Thu Jun 10, 2004 7:51 pm   Post subject: (No 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.



millionarie_v3.t
 Description:

Download
 Filename:  millionarie_v3.t
 Filesize:  16.84 KB
 Downloaded:  117 Time(s)

TrAnCeIn4LiFe




PostPosted: Sun Jun 13, 2004 9:08 am   Post subject: (No 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

Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: