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

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




PostPosted: Sun May 10, 2009 5:20 pm   Post subject: Exit Statement

how do you make an exit statement so that when q or Q is press then the loop will exit?
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Sun May 10, 2009 5:52 pm   Post subject: Re: Exit Statement

Well the function for checking if a key is pressed is hasch.

And you can exit a loop with exit.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Turing_Noob




PostPosted: Sun May 10, 2009 5:54 pm   Post subject: RE:Exit Statement

i've already tried

exit when hasch(81)

but it says error, can you give me the could that would do that
Dan




PostPosted: Sun May 10, 2009 6:06 pm   Post subject: RE:Exit Statement

Sorry, i thought you wanted it to exit when any char was hit.

What you will have to do is use hasch to check if a key was hit and then check if it was equal to 'q' or 'Q' with getch or getchar.

It would be somthing like this:

code:

If there was a key hit then
    exit when the key is 'q' or 'Q'
end if


Note that is pesdocode.


Edit: Input.KeyDown will also work. See the example for Input.KeyDown in the turing documentation.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
DanTheMan




PostPosted: Thu May 14, 2009 11:17 am   Post subject: RE:Exit Statement

if hasch "q" then
exit
end if
Dusk Eagle




PostPosted: Thu May 14, 2009 2:00 pm   Post subject: Re: Exit Statement

Dan, it's great that you're trying to help, but it helps no one when your code doesn't work. What Dan said above is probably the way to go.
BigBear




PostPosted: Thu May 14, 2009 2:17 pm   Post subject: RE:Exit Statement

You understand if you are getting input that it is hsch but you can't say if hasch "q"

you need to declare a string variable and get that variable then compare the vlue of that variable with "q" or "Q" You could look into getch aswell

(I pronounce it getch not get ch )
DanTheMan




PostPosted: Fri May 15, 2009 8:26 am   Post subject: Re: RE:Exit Statement

BigBear @ Thu May 14, 2009 2:17 pm wrote:
You understand if you are getting input that it is hsch but you can't say if hasch "q"

you need to declare a string variable and get that variable then compare the vlue of that variable with "q" or "Q" You could look into getch aswell

(I pronounce it getch not get ch )


Too right. That was my fault for leaving that out.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: