Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Go to http://pastebin.com/bVTNL6Np to obtain the text for junkfood.txt, save in the same folder as you are running Turing in. Turing will make junkfoodfixed.txt % and junkfoodfixed2.txt by itself
- var line1, line2, before, after : string
- var StreamNum1, StreamNum2, junkfound1, junkfound2, space2, space3, space4 : int
- open : StreamNum1, "junkfood.txt", get
- if StreamNum1 < 0 then
- put "File Access error: 404 or file not readable"
- else
- open : StreamNum2, "junkfoodfixed.txt", put
- loop
- exit when eof (StreamNum1)
- get : StreamNum1, line1 : *
- junkfound1 := index (line1, "Junk Food")
- junkfound2 := index (line1, "junk food")
- if junkfound1 > 0 then
- before := line1 (1 .. junkfound1 - 1)
- line2 := "Unhealthy Treats"
- after := line1 (junkfound1 + 9 .. *)
- line1 := before + line2 + after
- elsif junkfound2 > 0 then
- before := line1 (1 .. junkfound2 - 1)
- line2 := "unhealthy treats"
- after := line1 (junkfound2 + 9 .. *)
- line1 := before + line2 + after
- end if
- put : StreamNum2, line1
- end loop
- close : StreamNum1
- close : StreamNum2
- end if
- open : StreamNum1, "junkfoodfixed.txt", get
- if StreamNum1 < 0 then
- put "File Access error: 404 or file not readable"
- else
- open : StreamNum2, "junkfoodfixed2.txt", put
- loop
- exit when eof (StreamNum1)
- get : StreamNum1, line1 : *
- space4 := index (line1, " ")
- space3 := index (line1, " ")
- space2 := index (line1, " ")
- if space4 > 0 then
- before := line1 (1 .. space4)
- after := line1 (space4 + 3 .. *)
- line1 := before + after
- end if
- if space3 > 0 then
- before := line1 (1 .. space3)
- after := line1 (space3 + 2 .. *)
- line1 := before + after
- end if
- if space2 > 0 then
- before := line1 (1 .. space2)
- after := line1 (space2 + 1 .. *)
- line1 := before + after
- end if
- put line1
- put : StreamNum2, line1
- end loop
- close : StreamNum1
- close : StreamNum2
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement