Computer Science Canada

transfering text from one document to another

Author:  baby_bubblz [ Wed Jan 05, 2005 6:13 pm ]
Post subject:  transfering text from one document to another

hey, can someone please help me with a problem i have? it would be great..thanks!

question: how do you take text from a txt document (file)and transfer it into another txt (file2), but change it so that there are only 7 words on each line?

i know everything up to the part where you change the style of the text, i already declared the word and counter variable

get: file2, word
counter := counter + 1
if counter = 7 then
put '\n'

how do you restart the counter?

Author:  Cervantes [ Wed Jan 05, 2005 6:21 pm ]
Post subject:  Re: transfering text from one document to another

baby_bubblz wrote:

get: file2, word
counter := counter + 1
if counter = 7 then
put '\n'

how do you restart the counter?

code:

counter := 0

It looks like, in your code, you are getting data from file2. Maybe I misunderstood something, but aren't you supposed to write data to file2, and get the data from file1?

Author:  baby_bubblz [ Wed Jan 05, 2005 6:32 pm ]
Post subject: 

oh..yes it's supposed to be file1, sorry for the mistake

Author:  baby_bubblz [ Wed Jan 05, 2005 6:46 pm ]
Post subject: 

get: file1, word
counter := counter + 1
if counter = 7 then
put '\n'
put: file2, word
counter := 0
end if

is this correct?

Author:  Cervantes [ Wed Jan 05, 2005 7:29 pm ]
Post subject: 

Well, I haven't had much experience with files in Turing, but I don't think that's going to work. The reason? Look at the put statement. You're not putting the '\n' to file2, you're outputting it to the screen. Wink
Also, I don't know whether your method of putting a '\n' is viable. It may work, it may not. I'm not sure, it depends on how Turing deals with that character. In any case, try it out, and see what you get Smile

Lastly:
code:
[code][/code]tags are nice


: