Newbie question

G

Greg Lorriman

ruby 1.8.2 (2004-12-25) [i386-mswin32]

Hi folks,

I'm stumped by a syntax error. The error itself isn't telling me enough, I
think.

I'm attempting to run a unit test and here is the error message that results
:

"
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__':
../a
ppClasses.rb:153: syntax error (SyntaxError)
from d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`re
quire'
from D:/Data/Greg/dev/ruby/hg project/tc_appClasses.rb:1
"

I've looked at custom_require.rb and my newbie eyes can't see anything
amiss.

appClasses and tc_appClasses are my files. The syntax error is on the last
line of this in appClasses.rb :

class CostsToDatabase

def processCostsData(filepath,databasePath,*definitionFiles)
definition=Definition.new
definitionFiles.each do |df|
definition.setDefinitionFromFile!(df)
end
end

end # <syntax error pointing to here


I just can't see the trouble, although I'm pretty certain its related to the
test unit stuff.

Both my files are located here http://www.lorriman.com/deleteme/ if any kind
person needs to look at the whole code.

Thanks for any help,

Greg
 
J

James Edward Gray II

appClasses and tc_appClasses are my files. The syntax error is on
the last
line of this in appClasses.rb :

A "syntax error" on the last line almost always indicates a missing
"end". Get in the habit of checking that first when you see the
complaint. In this case, I believe you meant:

def setFromNativeRef!(nativeRef)
md=/\D+/.match(nativeRef)
if (!md)
raise 'Invalid cell reference :'+nativeRef
end # <= James added this line!
colStr=md[0].upcase
if colStr.length==2
high=colStr[0]-65
low=colStr[1]-65
@col=high*26+low
else
@col=colStr[0]-65
end
@col=md[0]
@row=md.post_match
self
end

Hope that helps.

James Edward Gray II
 
B

Belorion

ruby 1.8.2 (2004-12-25) [i386-mswin32]
=20
Hi folks,
=20
I'm stumped by a syntax error. The error itself isn't telling me enough, = I
think.

It looks like you haven't closed one of your if statements:

In appClasses.rb,

def setFromNativeRef!(nativeRef)
md=3D/\D+/.match(nativeRef)
if (!md) <---------------- This if does not have a corresponding end
raise 'Invalid cell reference :'+nativeRef
colStr=3Dmd[0].upcase
if colStr.length=3D=3D2=20
high=3DcolStr[0]-65
low=3DcolStr[1]-65
@col=3Dhigh*26+low =20
else
@col=3DcolStr[0]-65 =20
end
@col=3Dmd[0]
@row=3Dmd.post_match=20
self
end

If you want to use a single line if statement, use this:

raise 'Invalid cell reference :'+nativeRef if (!md)
 
P

Paolo Capriotti

ruby 1.8.2 (2004-12-25) [i386-mswin32]
=20
Hi folks,
=20
I'm stumped by a syntax error. The error itself isn't telling me enough, = I
think.

The real error line is 22:
21: if (!md)
22: raise 'Invalid cell reference :'+nativeRef
23: end # <-- this was missing
 
G

Greg Lorriman

Wonderful, thank you very much.

and apologies for sending you an emailed reply by mistake.

Greg
 
G

Greg Lorriman

A "syntax error" on the last line almost always indicates a missing
"end". Get in the habit of checking that first when you see the
complaint. In this case, I believe you meant:

I had considered that possibility, but in other languages the missing 'end'
marker tends to result in an error message closer to the mistake, and so I
didn't look back far enough through the code.

Thanks very much for your help.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top