Re: open("filename","rt"),for Bernie and others
- Posted by Al Getz <xaxo at AOL.COM> Nov 21, 2000
- 406 views
I forgot to mention that opening the file in the "rb" mode works for text files as well, but it then becomes necessary to detect the possible occurance of a #1A char in the program code as the following illustrates: --------------- include file.e include get.e object line atom fn1,ink,endchar --unrem these to add a hex 0x1A char to the end of a file for testing: --fn1=open("c:\\euphoria\\projects\\testsonly\\txtfile.txt","ab") --puts(fn1,#1A) --close(fn1) --open the file in "rb" mode but read it in with gets() while 1 do line=gets(fn1) if atom(line) then exit end if endchar=line[length(line)] if endchar=#0A or endchar=#1A then line=line[1..length(line)-1] end if printf(1,"%s\n",{line}) if endchar=#1A then exit end if end while close(fn1) ink=wait_key() ---------------