[plt-scheme] Help on newline when writing to a file

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Wed Jan 16 15:24:54 EST 2008

Try using

(define file (open-output-file "test.txt" 'text))

Chongkai

Marco Morazan wrote:
> I have the following code:
>
> (define file (open-output-file "test.txt"))
>
> (newline file)
> (display 5 file)
> (display '#\newline file)
> (display 4 file)
>
> (close-output-port file)
>
> When I open test.txt with notepad the newlines are displayed as little
> rectangles (i.e. rectangle 5 rectangle 4 ) -- no spaces all on the
> same line. Opening with wordpad gives me the expected display. What is
> going on here?
>
> I am using Windows XP.
>
> One more note, when I copy and paste from notepad to this message the result is:
>
> 5
> 4
>
> There is probably a trivial answer..........
>
> Thanks,
>
> Marco
>
>
>
>
>
>
> On Jan 9, 2008 9:23 PM, Lian DanHui <linda.lian at gmail.com> wrote:
>   
>> Sorry, my mistake. The error is caused by not opening file in Text Mode.
>>
>> Thanks again for all your valuable information.
>>
>>
>> On 1/10/08, Lian DanHui <linda.lian at gmail.com> wrote:
>>     
>>> Thanks all for your clarification on the line break!
>>>
>>> Now I find why I cannot see the line break in txt file.
>>>
>>> In Windows XP, I use windows Notepad to open the txt file.  And I cannot
>>>       
>> see the line break.
>>     
>>> Then I use gvim or windows Wordpad to open the txt file. And I can see the
>>>       
>> line break.
>>     
>>> I guess that NotePad didn't explain the line break well.
>>>
>>>
>>> On 1/9/08, Dave Gurnell <d.j.gurnell at gmail.com > wrote:
>>>       
>>>>>> Is there call for a platform specific line break escape here?
>>>>>>             
>>>>> I think that's best left to the port mode.
>>>>>           
>>>> Okay - I understand now. That makes a lot of sense.
>>>>
>>>> Cheers!
>>>>
>>>> -- Dave
>>>>
>>>> _________________________________________________
>>>> For list-related administrative tasks:
>>>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>>
>>>>         
>>>       
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>>
>>     
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.