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

Username:   Password: 
 RegisterRegister   
 2 words, 1 variable NEED HELP
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
beamer




PostPosted: Wed Nov 09, 2005 8:42 am   Post subject: 2 words, 1 variable NEED HELP

lol, can't believe that i'm asking this. Been so long since i used turing. How do you enter 2 words with one variable.
Ex: I enter Mr. Fun and all i get is Mr.
how do i get both words in?
Sponsor
Sponsor
Sponsor
sponsor
brokeded




PostPosted: Wed Nov 09, 2005 9:06 am   Post subject: (No subject)

I am not sure, but I think you add a star after the get statement.
But it might not work. maybe try it.

If it doesn't work, don't yell at me, im new to Turing Sad.

if you have ' get word '

or whatever you get....

then try having ' get word : * '
do_pete




PostPosted: Wed Nov 09, 2005 10:25 am   Post subject: (No subject)

yeah you do need :* after the variable or you can go "Mr. Fun" when you enter the words
Flikerator




PostPosted: Wed Nov 09, 2005 11:34 am   Post subject: (No subject)

var word : string
get word : *

Reason: It continues to get chars and as soon as it finds a space, chops the rest off. The * tells it to not stop at the space, and continue to collect chars.
Cervantes




PostPosted: Wed Nov 09, 2005 4:28 pm   Post subject: (No subject)

Flikerator wrote:
Reason: It continues to get chars and as soon as it finds a space, chops the rest off. The * tells it to not stop at the space, and continue to collect chars.


Sort of. You know how an asterisk represents a something? Such as any character, or any integer. In this case, it is representing any integer.
code:

var name : string
get name : 7
put name

Input "Bob Dylan". You should notice that only the first 7 characters are output, and the space is included in that.
Output wrote:

Bob Dyl

So really, it is the colon that is allowing for spaces to be accepted. Without the colon, Turing automatically breaks your input on spaces. With the colon, it breaks it where you tell it to.


An interesting note: Remember how Turing's strings can only be 255 characters long?
code:

var name : string
get name

Input about 4 and a half lines of "a"'s, and you'll crash it. Same goes for this:
code:

var name : string
get name : *

However, this protects against it:
code:

var name : string
get name : 255

Hence, there isn't really any point to using an asterisk there, when you could just use 255 and prevent that bug,
beamer




PostPosted: Fri Nov 11, 2005 12:43 pm   Post subject: (No subject)

lol, thanks guys, it's been a while since i've used turing.
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  [ 6 Posts ]
Jump to:   


Style:  
Search: