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

Username:   Password: 
 RegisterRegister   
 Help 2.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Thanos




PostPosted: Mon Sep 16, 2002 8:04 pm   Post subject: Help 2.

Hey, I was wondering what command I would use to assign a specific get command to a certain key. For example:

put "Hit the space bar to get your answer"

I want it so that everytime i hit the space bar (or any key) i will get the desired answer. Any help would be appreciated.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Sep 16, 2002 8:31 pm   Post subject: maybe its this

I'm a bit consufed but here's I think is what you're looking for.

code:
put "enter your name"
get name


this will promp the user to enter their name, after it was entered and return key is pressed, whatever was entered will be assigned to the variable name

I hope this is what you're looking for. I think Dan posted a tutorial on I/O, take a look there.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dan




PostPosted: Tue Sep 17, 2002 2:40 pm   Post subject: hummmm

if you whont it so you hit any key and dont need an enter you do this:

code:

var key :string (1) %make a var that is a string wiht only one char

put "Hit any key"
getch (key) %gets only one char from the key borad


the vlaue of the key hit is stored in the var but it can only be one char long.


to make it so it conutes when space is hit you coude do this:

code:

var key :string(1)

loop
        put ""
        put "hit spcae bar"
       
        getch (key) %get the key that was hit
       
        exit when key = " " %exit loop when key = a spcae
end loop

put "good bye"


this code will only exit when the space bar is hit. to make it nicer you coude add cls insted of the 1st put.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Thanos




PostPosted: Tue Sep 17, 2002 5:32 pm   Post subject: (No subject)

Thanks for all the help guys! Btw, does the "exit when" command only work with loops?
Tony




PostPosted: Tue Sep 17, 2002 6:48 pm   Post subject: (No subject)

exit when works for all loops, regular and for loop.
code:

for i:1..10
put i
exit when i=5
end for


will output only first 5 numbers then exit.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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: