[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

file.puts define newline

MrBanabas@googlemail.com

2/9/2009 1:44:00 PM

Hi,

just would like to know if I can somehow define the newline delimeter
when using file.puts ?
e.g. /n, /r/n

Thanks a lot in advance...
34 Answers

Jan-Erik R.

2/9/2009 1:50:00 PM

0

MrBanabas@googlemail.com schrieb:
> Hi,
>
> just would like to know if I can somehow define the newline delimeter
> when using file.puts ?
> e.g. /n, /r/n
>
> Thanks a lot in advance...
>
hm...I don't think so.
Can't you use file.print and append a "\r\n" or whatever you need?

MrBanabas@googlemail.com

2/9/2009 2:44:00 PM

0

On 9 Feb., 14:50, badboy <bad...@heartofgold.co.cc> wrote:
> MrBana...@googlemail.com schrieb:> Hi,
>
> > just would like to know if I can somehow define the newline delimeter
> > when using file.puts ?
> > e.g. /n, /r/n
>
> > Thanks a lot in advance...
>
> hm...I don't think so.
> Can't you use file.print and append a "\r\n" or whatever you need?

Sure I can do that, but I thought it would be "cleaner" if I could to
something like:
file = new File....
file.newline_delimiter = '/r/n'
or
file.newline_delimiter = 'dos'

--
Volker

Jan-Erik R.

2/9/2009 2:49:00 PM

0

MrBanabas@googlemail.com schrieb:
> On 9 Feb., 14:50, badboy <bad...@heartofgold.co.cc> wrote:
>> MrBana...@googlemail.com schrieb:> Hi,
>>
>>> just would like to know if I can somehow define the newline delimeter
>>> when using file.puts ?
>>> e.g. /n, /r/n
>>> Thanks a lot in advance...
>> hm...I don't think so.
>> Can't you use file.print and append a "\r\n" or whatever you need?
>
> Sure I can do that, but I thought it would be "cleaner" if I could to
> something like:
> file = new File....
> file.newline_delimiter = '/r/n'
> or
> file.newline_delimiter = 'dos'
>
> --
> Volker
>
ugly... newline_delimiter = '/r/n' wouldn't work as you expected =D
it should be \r\n right?

7stud --

2/9/2009 4:26:00 PM

0

MrBanabas@googlemail.com wrote:
> On 9 Feb., 14:50, badboy <bad...@heartofgold.co.cc> wrote:
>> MrBana...@googlemail.com schrieb:> Hi,
>>
>> > just would like to know if I can somehow define the newline delimeter
>> > when using file.puts ?
>> > e.g. /n, /r/n
>>
>> > Thanks a lot in advance...
>>
>> hm...I don't think so.
>> Can't you use file.print and append a "\r\n" or whatever you need?
>
> Sure I can do that, but I thought it would be "cleaner" if I could to
> something like:
> file = new File....
> file.newline_delimiter = '/r/n'
> or
> file.newline_delimiter = 'dos'

You are supposed to be able to do this:

$OUTPUT_RECORD_SEPARATOR = "apple"

f = File.open("data.txt", "w")
f.write "hello world"
f.write "goodbye"
f.close()

but the output I get in data.txt is:

hello worldgoodbye
--
Posted via http://www.ruby-....

7stud --

2/9/2009 4:41:00 PM

0

7stud -- wrote:
> You are supposed to be able to do this:
>
> $OUTPUT_RECORD_SEPARATOR = "apple"
>
> f = File.open("data.txt", "w")
> f.write "hello world"
> f.write "goodbye"
> f.close()
>
> but the output I get in data.txt is:
>
> hello worldgoodbye

Ok, I found one combination that allows me to define the output
separator:

1) Use this assignment:

$\ = "apple"

2) And the new output record separator only works with print(), not
write():

#$OUTPUT_FIELD_SEPARATOR = "apple"
$\ = "apple"

x = "hello world"
y = "goodbye"

f = File.open("data.txt", "w")
f.write x
f.write y
f.close #data.txt => hello worldgoodbye

STDOUT.write x
STDOUT.write y #terminal => hello worldgoodbye


f = File.open("data.txt", "w")
f.print x
f.print y
f.close #data.txt => hello worldapplegoodbyeapple

print x
print y #terminal => hello worldapplegoodbyeapple





--
Posted via http://www.ruby-....

7stud --

2/9/2009 4:41:00 PM

0

7stud -- wrote:
> Ok, I found one combination that allows me to define the output
> separator:
>

Mac OSX 10.4.11
--
Posted via http://www.ruby-....

amurawa

3/16/2011 12:22:00 AM

0

On Mar 15, 3:49 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
> "Sydney of Astatula" <S...@mps.com> wrote in messagenews:Xns9EA9B3BAA5F4ESYD@209.197.15.205...
>
> > I believe some of the music (Ratdog, Furthur, The Other Ones,
> > Phil Lesh and Friends, etc) remains serious, and in some ways
> > is better than the Dead were in some of their worst eras
> > (82 thru 85, 92 thru 95). .
>
> This statement is far more disturbing than what you're
> originally complaining about.

Right. How is 86 thru 88 excluded here?

3jane.

3/16/2011 2:26:00 PM

0

On Mar 15, 8:22 pm, Andrew <amur...@hotmail.com> wrote:
> On Mar 15, 3:49 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
>
> > "Sydney of Astatula" <S...@mps.com> wrote in messagenews:Xns9EA9B3BAA5F4ESYD@209.197.15.205...
>
> > > I believe some of the music (Ratdog, Furthur, The Other Ones,
> > > Phil Lesh and Friends, etc) remains serious, and in some ways
> > > is better than the Dead were in some of their worst eras
> > > (82 thru 85, 92 thru 95). .
>
> > This statement is far more disturbing than what you're
> > originally complaining about.
>
> Right. How is 86 thru 88 excluded here?

I agree with that statement, it's a good thing 72-75 shows are keepers
because those 2 later 3 year stretches are the nadir of the Dead
(IMO), though 85 is better than 83-84. If someone is talking on a
cell phone next to you, ask them nicely to keep it down and if they
keep doing it tell them to STFU, that works quite well for me-however
the Op's point is well taken.

grunk

3/16/2011 6:04:00 PM

0

On Mar 15, 6:49 pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
> "Sydney of Astatula" <S...@mps.com> wrote in messagenews:Xns9EA9B3BAA5F4ESYD@209.197.15.205...
>
> > I believe some of the music (Ratdog, Furthur, The Other Ones,
> > Phil Lesh and Friends, etc) remains serious, and in some ways
> > is better than the Dead were in some of their worst eras
> > (82 thru 85, 92 thru 95). .
>
> This statement is far more disturbing than what you're
> originally complaining about.

Exactly!
While I don't really care to get myself involved in your first
statement, the second is a whole other beast.
The writing off of 82 - 85 as being a part of "some of their worst
eras" is simply NUTS!!
Don't tell me, let me guess, you're one of those people who would take
just about any show from May of '77 over large bits of '73 - "75, as
well, yes?
If I am mistaken, well than please let me take this opportunity to
apologize, but if this is the case, well, it would go a rather long
way towards explaining, to me anyway, exactly why you are so uptight!!

Sydney of Astatula

3/16/2011 10:00:00 PM

0

grunk wrote in
news:7b926ae0-909b-4b6e-9ce4-7a62878447f0@o30g2000pra.googlegroups.com:

> On Mar 15, 6:49?pm, "sweetbac" <sweet...@sbcglobal.net> wrote:
>> "Sydney of Astatula" <S...@mps.com> wrote in
>> messagenews:Xns9EA9B3BAA5F4E
> SYD@209.197.15.205...
>>
>> > I believe some of the music (Ratdog, Furthur, The Other Ones,
>> > Phil Lesh and Friends, etc) remains serious, and in some ways
>> > is better than the Dead were in some of their worst eras
>> > (82 thru 85, 92 thru 95). .
>>
>> This statement is far more disturbing than what you're
>> originally complaining about.
>
> Exactly!
> While I don't really care to get myself involved in your first
> statement, the second is a whole other beast.
> The writing off of 82 - 85 as being a part of "some of their worst
> eras" is simply NUTS!!
> Don't tell me, let me guess, you're one of those people who would take
> just about any show from May of '77 over large bits of '73 - "75, as
> well, yes?
> If I am mistaken, well than please let me take this opportunity to
> apologize, but if this is the case, well, it would go a rather long
> way towards explaining, to me anyway, exactly why you are so uptight!!
>

You act as though you have some objective measurement of the quality of
a particular era. 77 is indeed regarded as the Dead's best year by many.
This is attributable to the making of Terrapin Station where Keith Olsen
demanded perfection and made the band rehearse for literally hundreds of
hours in preparation for the studio. Garcia gained a higher level of
virtuosity as a consequence and many regard this as the peak of his
playing. I would agree that the early 70's was the era where the Dead
did their best writing, and it was perhaps the last era for which there
was genuine improvisation onstage. The 82 thru 85 era is fully detailed
in Rock Scully's book where Garcia's addiction to persian heroin had
become so bad that his playing had slowed to the point "where ten notes
were used where there used to be a hundred". This was the era where
Jerry repeatedly nodded off with a cigarette burning which led to
several cases where the sofa caught on fire. His hair was singed and his
fingers were burnt from using the lighter to "chase the dragon". All in
all, the persian took its toll onstage and off, the worst casualty being
his playing. The reason for the decline in 92 thru 95 is obvious,
Jerry's health had severely deteriorated, he couldn't remember lyrics,
he used a teleprompter and while his playing still conveyed a beauty
that no other guitarist has ever matched, especially on the slow songs,
his playing began to deteriorate as he approached his end. If you ask me
today my favorite year, I will not give you the same answer I will give
tomorrow - my moods are not so consisten. What I can say is that my
favorite years for live performances include 69, 72, 77, 80,89, & 90.
But this is a very subjective topic - nobody can say definitively which
year was best - we are all entitled to our opinions and for something as
subjective as this issue, they are all equally valid.