
-----------------------------------
StarFeind
Thu Jun 02, 2011 3:45 pm

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.

-----------------------------------
Insectoid
Thu Jun 02, 2011 4:05 pm

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.

-----------------------------------
StarFeind
Fri Jun 03, 2011 9:21 am

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

-----------------------------------
Tony
Fri Jun 03, 2011 11:45 am

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 [tdoc]get[/tdoc] -- it's lengthy, but it actually has code examples for what you are looking for.

-----------------------------------
StarFeind
Fri Jun 03, 2011 1:03 pm

Re: Large amount of text - linking to file?
-----------------------------------
Thank you both :) I'll go and read through that and see what i can do.
