How do I use heredocs

Hi,

I have a simple test program.

···

====================
class QuickTest
        def testMe
        str = <<EOS
         Some Application data
EOS puts str
    end
  end

if $0 == __FILE__ then

    $test = QuickTest.new
    $test.testMe
end ===========================

I got this error and could not figure out what's wrong?

==============================================
QuickTest.rb:21: can't find string "EOS" anywhere before EOF
QuickTest.rb:6: syntax error

Can someone help?

I am running Ruby 1.8 on Windows XP

Thanks

Hi --

···

On Fri, 12 Aug 2005, hsun wrote:

Hi,

I have a simple test program.

====================
class QuickTest
     def testMe
      str = <<EOS
       Some Application data
EOS puts str
  end end

if $0 == __FILE__ then

  $test = QuickTest.new
  $test.testMe
end ===========================

I got this error and could not figure out what's wrong?

==============================================
QuickTest.rb:21: can't find string "EOS" anywhere before EOF

You need to put EOS on a line by itself.

David

--
David A. Black
dblack@wobblini.net

Works fine for me.

Are you 100% sure that "EOS" begins in column 0? This must be true or
it will not be found. Otherwise, change to <<-EOS, where the - will
let you indent the terminator.

Jason

···

On 8/11/05, hsun <sunh11373@hotmail.com> wrote:

Hi,

I have a simple test program.

====================
class QuickTest

    def testMe
        str = <<EOS
         Some Application data
EOS
        puts str
    end

end

if $0 == __FILE__ then

    $test = QuickTest.new
    $test.testMe
end

I got this error and could not figure out what's wrong?

==============================================
QuickTest.rb:21: can't find string "EOS" anywhere before EOF
QuickTest.rb:6: syntax error

Can someone help?

I am running Ruby 1.8 on Windows XP

Thanks

Your program is failing because you have 12 spaces after the "EOS".
You can't have anything on the line after the here-document terminator,
not even whitespace.

hsun <sunh11373@hotmail.com> writes:

···

Hi,

I have a simple test program.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
class QuickTest
  =20
   def testMe
       str =3D <<EOS
        Some Application data
EOS =20
       puts str
   end =20
=20
end

if $0 =3D=3D __FILE__ then

   $test =3D QuickTest.new
   $test.testMe
end =20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D

I got this error and could not figure out what's wrong?

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
QuickTest.rb:21: can't find string "EOS" anywhere before EOF
QuickTest.rb:6: syntax error
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Can someone help?

I am running Ruby 1.8 on Windows XP

Thanks

Hello David,

The message messed up but I am sure that the EOS is on its own line by itself and I even checked with a HEX editor. Here is the file atached.

The editor I use is Mondrain.

Thanks

QuickTest.rb (219 Bytes)

···

Hi --

On Fri, 12 Aug 2005, hsun wrote:

Hi,

I have a simple test program.

====================
class QuickTest
def testMe
str = <<EOS
Some Application data
EOS puts str
end end
if $0 == __FILE__ then

$test = QuickTest.new
$test.testMe
end ===========================
I got this error and could not figure out what's wrong?

==============================================
QuickTest.rb:21: can't find string "EOS" anywhere before EOF

You need to put EOS on a line by itself.

David

I opened you attachment and it bombed on me as well. But when I selected the line afetr the terminating EOS I saw that you definitely did have about 12 spaces after the EOS. I am attching your file back and now it works.
HTH
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com

QuickTest.rb (190 Bytes)

Hello Ezra,

Thanks, it works now. maybe I should trun the EOL mark on from now on.

Thanks for everyone that offered help

···

I opened you attachment and it bombed on me as well. But when I
selected the line afetr the terminating EOS I saw that you definitely
did have about 12 spaces after the EOS. I am attching your file back
and now it works.
HTH
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com
On Aug 11, 2005, at 2:19 PM, hsun wrote:

Hello David,

The message messed up but I am sure that the EOS is on its own line
by itself and I even checked with a HEX editor. Here is the file
atached.

The editor I use is Mondrain.

Thanks

Hi --

On Fri, 12 Aug 2005, hsun wrote:

Hi,

I have a simple test program.

====================
class QuickTest
def testMe
str = <<EOS
Some Application data
EOS puts str
end end
if $0 == __FILE__ then
$test = QuickTest.new
$test.testMe
end ===========================
I got this error and could not figure out what's wrong?

QuickTest.rb:21: can't find string "EOS" anywhere before EOF

You need to put EOS on a line by itself.

David

<QuickTest.rb>

hsun wrote:

Hello Ezra,

Thanks, it works now. maybe I should trun the EOL mark on from now on.

Having the editor remove trailing white space automatically when saving is
a good idea. This feature is present in almost every serious editor.

    robert

···

Thanks for everyone that offered help

I opened you attachment and it bombed on me as well. But when I
selected the line afetr the terminating EOS I saw that you definitely
did have about 12 spaces after the EOS. I am attching your file back
and now it works.
HTH
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra@yakima-herald.com
On Aug 11, 2005, at 2:19 PM, hsun wrote:

Hello David,

The message messed up but I am sure that the EOS is on its own line
by itself and I even checked with a HEX editor. Here is the file
atached.

The editor I use is Mondrain.

Thanks

Hi --

On Fri, 12 Aug 2005, hsun wrote:

Hi,

I have a simple test program.

====================
class QuickTest
def testMe
str = <<EOS
Some Application data
EOS puts str
end end
if $0 == __FILE__ then
$test = QuickTest.new
$test.testMe
end ===========================
I got this error and could not figure out what's wrong?

QuickTest.rb:21: can't find string "EOS" anywhere before EOF

You need to put EOS on a line by itself.

David

<QuickTest.rb>

And even in some of the flippant ones.

···

On Aug 12, 2005, at 2:01 AM, Robert Klemme wrote:

Having the editor remove trailing white space automatically when saving is
a good idea. This feature is present in almost every serious editor.

Gavin Kistner wrote:

···

On Aug 12, 2005, at 2:01 AM, Robert Klemme wrote:

Having the editor remove trailing white space automatically when saving is
a good idea. This feature is present in almost every serious editor.

And even in some of the flippant ones.

Please see http://compsoc.dur.ac.uk/whitespace/index.php for a "language" consisting entirely of whitespace. Great fun!

--
Daryl Richter
Platform Author & Director of Technology
v: 610.361.1000 x202

(( Brandywine Asset Management )
  ( "Expanding the Science of Global Investing" )
  ( http://www.brandywine.com ))

Or the Whiteout Ruby Quiz, for our version: :wink:

http://www.rubyquiz.com/quiz34.html

James Edward Gray II

···

On Aug 12, 2005, at 11:06 AM, Daryl Richter wrote:

Please see http://compsoc.dur.ac.uk/whitespace/index.php for a "language" consisting entirely of whitespace. Great fun!