Computer Science Canada

Large amount of text - linking to file?

Author:  StarFeind [ Thu Jun 02, 2011 3:45 pm ]
Post subject:  Large amount of text - linking to file?

I am taking my first programing course in high school ( grade 11) and for our final project we need to create a game of our choice with various specifics. The problem is that I have a large amount of text I want to put in my game, but I know there must be a way to make it take up less code then so many put statements. I have gone through the school turing book but cant find anything that seems to work. I'm kinda looking for some way to get the program to go to a file and print whats in that file onto the screen.

( To clarify I would ask my teacher for help but he had a heart attack at the beginning of the semester and our new teacher doesn't know much about turing so he hasn't been much of a help :/.) Sorry if I missed a tutorial on this stuff, but I hope somebody can help, My school has turing version 4 I think.

Author:  Insectoid [ Thu Jun 02, 2011 4:05 pm ]
Post subject:  RE:Large amount of text - linking to file?

use File.Open() and File.Close(). You can then use a get() statement to read text from the file you opened. Specifics can be found in the docs, or in the Turing Walkthrough.

Author:  StarFeind [ Fri Jun 03, 2011 9:21 am ]
Post subject:  Re: Large amount of text - linking to file?

ok i got this far but it only prints the first word of the file, I need all words to be opened, do i need to add something to the code, or did i mess up?

var stream : int
var intro : string := ""
open : stream, "Intro.txt", get
get : stream, intro

put stream,intro

Author:  Tony [ Fri Jun 03, 2011 11:45 am ]
Post subject:  RE:Large amount of text - linking to file?

That's a start. get is whitespace delimited, so would fetch only up to the first space/newline. Read the docs for get -- it's lengthy, but it actually has code examples for what you are looking for.

Author:  StarFeind [ Fri Jun 03, 2011 1:03 pm ]
Post subject:  Re: Large amount of text - linking to file?

Thank you both Smile I'll go and read through that and see what i can do.


: