Computer Science Canada Reading spaces in Turing |
Author: | Luganchan [ Thu Nov 28, 2013 1:11 pm ] |
Post subject: | Reading spaces in Turing |
What is it you are trying to achieve? I am trying to make an english to morse decoder/encoder in Turing. What is the problem you are having? In morse, letters are separated by a space, while words are separated by three spaces. The problem is that Turing does not read the spaces in between the words within a string.When we input "Magic The Gathering", we get the morse output for MagicTheGathering, turing won't read the spaces. Please specify what version of Turing you are using Turing 4.1 |
Author: | DemonWasp [ Thu Nov 28, 2013 1:35 pm ] |
Post subject: | RE:Reading spaces in Turing |
Without seeing your code it's hard to be sure exactly what's wrong, but I assume that you're not using 'get' correctly. Look at http://compsci.ca/holtsoft/doc/get.html , specifically part (c), and the bit about "Line-oriented input". |
Author: | Raknarg [ Thu Nov 28, 2013 3:12 pm ] |
Post subject: | RE:Reading spaces in Turing |
Are you using get statements? Try this: get input :* The ":*" after it tells Turing to obtain the entire line you type. If you don't include it, it will only take the first word you input. Is this your problem? |
Author: | Luganchan [ Thu Nov 28, 2013 5:55 pm ] |
Post subject: | RE:Reading spaces in Turing |
I use the get input :* but it does not register spaces as part of the string |
Author: | Raknarg [ Thu Nov 28, 2013 6:06 pm ] |
Post subject: | Re: Reading spaces in Turing |
Are you certain you did it correctly? |
Author: | Luganchan [ Thu Nov 28, 2013 6:58 pm ] | ||
Post subject: | Re: Reading spaces in Turing | ||
this is the part of my code that is in question, i got it to work, but the spaces it outputs in morse take up multiple line upon output.
|
Author: | Raknarg [ Thu Nov 28, 2013 7:42 pm ] |
Post subject: | RE:Reading spaces in Turing |
it took me some time, but I figured it out. Go over your code when the letter is a space. It goes over that code 53 times. Think about it. |
Author: | DemonWasp [ Thu Nov 28, 2013 7:59 pm ] |
Post subject: | RE:Reading spaces in Turing |
Seems to be working fine for me, except that you're printing those four spaces 53 times for every space that occurs in 'word'. |
Author: | Luganchan [ Thu Nov 28, 2013 8:01 pm ] |
Post subject: | Re: Reading spaces in Turing |
wow, can't beleive i didn't notice that, thank everyone |