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

Username:   Password: 
 RegisterRegister   
 error check with multi-word variables
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
batgirl13




PostPosted: Thu Dec 04, 2008 8:08 pm   Post subject: error check with multi-word variables

hi,
im making a simple program; here is a section of the code.

code:

loop
     put "Would you like to enter? Y/N" ..
     get ans
     if ans = Y then
          exit
     elsif ans = N then
          quit
     else
          put ans, " is not a correct response."
     end if
end loop


at the moment, if you enter more than 1 word, it will display the error message once for every word. i need it to display once, showing all words that may have been entered. i know this is a simple fix, but i cant remember how to do it...help would be much appreciated. Smile
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Thu Dec 04, 2008 8:20 pm   Post subject: Re: error check with multi-word variables

I think it's:
code:
get thingy :*


You might also wonna watch out for Y & N since they appear to be strings be sure to add the "Y".
andrew.




PostPosted: Thu Dec 04, 2008 11:25 pm   Post subject: RE:error check with multi-word variables

Zren is right. Just add : * after your get line.

code:
get ans : *


And yeah, you definitely have to change it from saying if ans = Y to if ans = "Y".
Tyr_God_Of_War




PostPosted: Thu Dec 04, 2008 11:30 pm   Post subject: RE:error check with multi-word variables

And if you use index it will sort through the response for a phrase. I will post an example if you want.
batgirl13




PostPosted: Thu Dec 04, 2008 11:45 pm   Post subject: RE:error check with multi-word variables

ahh, thank you, knew it was something easy Smile

and thanks for the "" as well, i had those in the original program but forgot to type them in.
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: