Re: File input.output
- Posted by irv <irv at ELLIJAY.COM> Aug 27, 2000
- 537 views
On Sun, 27 Aug 2000, BOB wrote: > I would like to be able to SAVE a sequence of floating point numbers(say a > few hundred) to a file in one PUTS and then retrieve > that data from file back into a sequence in one GETS. > Looking at the documentation of GETS it would seem that I can't. > Secondly will I be able to look at what's in the file using Explorer to see > if I have filed the right information. > Really all I'm trying to do is to SAVE and LOAD a 'sequential file' reasonably > quickly. > Regards It looks like you've gotten several answers, but based on your requirements, I also to suggest using print() and get(). It's quick and easy, and hard ato break. -- tested code: include get.e object numbers numbers = {1.23, 3.14159, 6, 8, -23.5, 12.99} atom fn fn = open("my.dat","w") print(fn, numbers) close(fn) fn = open("my.dat","r") numbers = get(fn) close(fn) if numbers[1] = GET_SUCCESS then numbers = numbers[2] else puts(1,"ERROR READING FILE") end if ? numbers If you plan to store lots of strings in your files, you really need to downloading Gabriel Boehme's PRINT.E - this small library causes the print() function to write text in plain, human readable form, while still being readable by Euphoria's get() function. I have been using this method for many months in several commercial programs without any problems These programs typically read (modify) and write files of about half a meg hundreds of times each day. By the way, these files will be plain text, so probably NotePad or similar would be just fine for viewing them. Regards, Irv