Think of something that you wish Authorware could do but it doesn't?  Let the our good friends at Macromedia know via the wishlist.

Please let us know if you find any of the materials on this site inappropriate or offensive. Please include the url and why the material should be reviewed.

Comments and questions about the site are also welcome. Please no Authorware questions, use the AWARE list.

Back

1053 - How do I read data from a text file?

by - Joseph Ganci


I am able to read in an external file eg test1a.txt using the line below. For a beginner, this is a big step! temp:=ReadExtFile(FileLocation^"data\\section1\\test1a.txt") My next request: I have a folder (eg data\section1) containing a number of text files which are retrieved one by one as the program user requires. eg test 1a.txt, test1b.txt, etc. These are selected by a menu on screen.

Is there a way of inserting the title of a retrieved file - eg "test1a" (and without the file ending) to appear in my program. I have tried : CurrentFile:=Catalog(FileLocation^"data\\section1") but that reads in all files (and endings) from the folder. And then I suppose I would use GetLine to retrieve the title of the one in use. But that seems complicated as I would then have to record the user's file selection from the menu somewhere. Which I dont know how to do!

1. Is there perhaps an easier way in using the temp function above, which is already in my calc icon, to do this?
2. Alternatively, could I make use of the map icon titles I have used to separately hold the 'test1a', 'test1b', etc? These map icons are titled test1a, test1b, etc

Sounds as if you've set everything up ready, now you just need to get across the finish line. Since your Map icons are already named the same as the files you want to read, you can attach a Calc ornament to each map:

yfile := icontitle

then you can use:

temp:=ReadExtFile(FileLocation^"data\\section1\\"^myfile)

There are 0 reviews
Add your review
Back