Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dumb mistake in 11-line script; any insights?

Skip to first unread message

RichardOnRails

unread,
Jan 25, 2012, 1:34:33 AM1/25/12
to
Hi,

I have the 11-line script below. Ruby 1.9.3 barfs on line 8 with the
error msg in the comment on that line.

Script
=====
print "Search what: D = Docs; C = Current
what = gets.chomp
wk_dir = case what
when /^[Dd]/
Dir.chdir ".."
Dir.pwd
when /^[Cc]/
"K:\\___Current" # syntax error, unexpected tCONSTANT, expecting
$end
else
puts "Invalid choice \"%s\"" % what && exit
end

Christian Neukirchen

unread,
Jan 25, 2012, 10:04:32 AM1/25/12
to
RichardOnRails <RichardDummy...@USComputerGurus.com> writes:

> Hi,
>
> I have the 11-line script below. Ruby 1.9.3 barfs on line 8 with the
> error msg in the comment on that line.

> print "Search what: D = Docs; C = Current
^ Missing "

--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org

RichardOnRails

unread,
Jan 25, 2012, 12:04:47 PM1/25/12
to
On Jan 25, 10:04 am, Christian Neukirchen <chneukirc...@gmail.com>
wrote:
> RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> writes:
> > Hi,
>
> > I have the 11-line script below.  Ruby 1.9.3 barfs on line 8 with the
> > error msg in the comment on that line.
> > print "Search what: D = Docs; C = Current
>
>                                            ^ Missing "
>
> --
> Christian Neukirchen  <chneukirc...@gmail.com>  http://chneukirchen.org

Thanks, Christian. It's strange that the missing quote didn't cause a
syntax error on earlier statements.
--
Ricard

Christian Neukirchen

unread,
Jan 25, 2012, 3:08:11 PM1/25/12
to
RichardOnRails <RichardDummy...@USComputerGurus.com> writes:

> On Jan 25, 10:04 am, Christian Neukirchen <chneukirc...@gmail.com>
> wrote:
>> RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> writes:
>> > Hi,
>>
>> > I have the 11-line script below.  Ruby 1.9.3 barfs on line 8 with the
>> > error msg in the comment on that line.
>> > print "Search what: D = Docs; C = Current
>>
>>                                            ^ Missing "
>
> Thanks, Christian. It's strange that the missing quote didn't cause a
> syntax error on earlier statements.

Multi-line strings are no problem in Ruby:

string = "that spans
multiple
lines"

I'd recommend you to get an editor with smart indentation (or syntax
highlighting, if you prefer). It will discover such errors quickly.

RichardOnRails

unread,
Jan 28, 2012, 11:17:18 PM1/28/12
to
On Jan 25, 3:08 pm, Christian Neukirchen <chneukirc...@gmail.com>
wrote:
> RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> writes:
> > On Jan 25, 10:04 am, Christian Neukirchen <chneukirc...@gmail.com>
> > wrote:
> >> RichardOnRails <RichardDummyMailbox58...@USComputerGurus.com> writes:
> >> > Hi,
>
> >> > I have the 11-line script below.  Ruby 1.9.3 barfs on line 8 with the
> >> > error msg in the comment on that line.
> >> > print "Search what: D = Docs; C = Current
>
> >>                                            ^ Missing "
>
> > Thanks, Christian.  It's strange that the missing quote didn't cause a
> > syntax error on earlier statements.
>
> Multi-line strings are no problem in Ruby:
>
> string = "that spans
> multiple
> lines"
>
> I'd recommend you to get an editor with smart indentation (or syntax
> highlighting, if you prefer).  It will discover such errors quickly.
>
> --
> Christian Neukirchen  <chneukirc...@gmail.com>  http://chneukirchen.org

Thanks for your additional advice. I use SciTE, which fortunately
provides syntax coloring. I did notice some odd coloring but didn't
notice anything wrong and mistakenly focused on the code lower down.
I was just too sloppy.

Again, thank you,
Richard
0 new messages