Opening text files

I though I followed the instructions, but it continues to say the file does not exist.

I placed it in materials, without an extension, and with .glkdata, in both cases, I get a runtime error saying the file does not exist.

Help please, thank you.

Could you post the relevant part of your code, and the exact name of the file and directory where you put it?

(Also, if you are using Windows: make sure that “hide known file extensions” or whatever they call it is off. Your file might have an extension without you seeing it.)

The file of flexiblestory is called “flexible1”.

Elsewhere:

read file of flexiblestory into table of story reading;

Extensions are visible, for sure. I’ve tried flexible1, flexible1.txt, flexible1.glkdata, this is in the materials folder.

Do ‘file’ require another folder? I don’t know, the docs don’t say. It’s very specific for figures and sounds.

The interpreter gets to choose where to look for a file, so it will depend how you are running your story. Most interpreters will look in the user’s home directory or maybe the My Documents folder on Windows, but there are other possibilities: the Mac IDE, for instance, looks in the folder containing the current project’s .inform file. You can find out what folder and file extension to use by creating a small project:There is a room. The file for testing is called "MyFile". When play begins: write "" to the file for testing.
running it, and then search your computer for MyFile.

Edit: forgot that I7 names for files need to begin with the word ``file.’’

Did you make the text file yourself? The problem is that the ‘read file… into table’ command, which in your case is:

read file of flexiblestory into table of story reading;

does not work for user created files. That command is only for reading data from a file which was created by your game itself.

I had a glance at the docs and it looks like Inform can write to text files, but its only way of reading them is to dump the whole file to the screen with this command:

say "[text of external file]"

So you could put your text file data into a table in Inform, then write a file from the table using Inform’s commands which can then be read back in your game another time, but I don’t think you can use your own text file for random access reading and writing.

Don’t forget that when you store a text containing a substitution (like “[text of external file]”) as indexed text, the substitution gets expanded. In this way you can read a plain text file into indexed text, and you can also write indexed text back, again by way of a substitution. But you’re right that the posted code won’t work unless the file adheres to Inform’s format for saved tables.

It’s searching now. This is windows 7, Inform 7, if that helps at all. Thanks for your input one and all.

Got it. It put it… on my desktop? Wow.

Confound it! It didn’t include the file in the gblorb? It produces a runtime error when run out of quixe.

Right. Inform knows that the file will be looked for in another location like the Desktop or a folder owned by the browser, not the blorb, so it doesn’t package it. Maybe we can be more helpful if you tell us what your high-level goal is?

Well, the blorb is posted on a web site, and quixe is used to play it, via inform’s built in ‘release with interperter’ function.

I want it to be able to play this rather long winded text file when someone looks at a book.

In that case it’s probably easiest just to break the text file up into Inform say phrases (the conversion could be automated, but if it’s that long I pity your readers). I’m not seeing any good way for a story to pull a text chunk out of its blorb, given that the Glk documentation on the blorb layer doesn’t mention a suitable usage value:

But someone else might have a better suggestion.

This makes me sad…

Thanks for the help though.

AFAIK, Quixe cannot create or access text files in the file system. Instead it manages its own files with local storage.

Say, a related question, is there any way for players to perserve their saves between versions with quixe?

What do you mean by between versions?

No, Inform’s VM model only allows save files to work with the exact same game file that created them. Quixe can’t change that fact.

Life is full of dissapointments, but you guys were great, thanks.