Re: Simple I/O Problem
- Posted by ChrisB (moderator) May 15, 2016
- 1351 views
Icy_Viking said...
Hello,
So I am working with some simple file I/O, however when I go to test it, nothing appears on the screen.
atom handle object line handle = open("myfile.txt","w") if handle = -1 then puts(1,"Could not create file!") else print(handle,"hello") end if close(handle) handle = open("myfile.txt","r") if handle = -1 then puts(1,"Could not open file!") else line = gets(handle) --add this puts(1, line) --also should do more error checking on line in case read past end of file --(this is instead of above) if sequence(line) then puts(1, line) else puts(1, "End of file reached\n") end if --also you should be looping to read subsequent lines, or use read_lines to read the whole file at once end if close(handle)
Any help as to why nothing appears on the screen. I am missing a simple step, a bug? It should create the text file, then read the text file and output what was in the text file. I am using Euphoria 4.0.5 and Windows 7 64-bit Ultimate.
Cheers
Chris