[fxruby-users] (no subject)

Lyle Johnson lyle at lylejohnson.name
Wed Jan 28 08:32:24 EST 2009

On Jan 28, 2009, at 2:55 AM, dave L wrote:

> here is my source
> require "inchesX"
> Class inchesX
>          #events
>   def init
>     convertButton.connect(SEL_COMMAND){
>             cmLabel.text = (inchesField.text.to_f * 2.54).to_s}
>   end
> #unit test
> if __FILE__==$0
>     require "FX"
>         app=App.new
>     w=inchesX.new app
>     w.topwin.show(0)
>     app.create
>     app.run
> end
> and here is the error i get when run from teh terminal (using kate  
> to code wit a terminal at the bottom so i don't have to flick  
> between windows/programs.
> dave at AMD3000:/spare/foxgui$ ruby ExtendInches.rb
> ExtendInches.rb:2: undefined local variable or method `inchesX' for  
> main:Object (NameError)

This is an odd-looking program. It's tough to know where to begin.

One obvious problem you're running into is that class names in Ruby  
must begin with an uppercase letter. You will need to rename your  
"inchesX" class to "InchesX".

Also, the code that you're showing is incomplete:

	class inchesX
		def init
			convertButton.connect(SEL_COMMAND) { cmLabel.text =  
(inchesField.text.to_f*2.54).to_s }

There's no "end" statement corresponding to the "class" statement, so  
I'm surprised this parsed at all. What does the contents of the  
"inchesX.rb" file look like?

In your main program (i.e. the part in the "if __FILE__" block), you  

	inchesX.new app

but unless the code in "inchesX.rb" contains a corresponding  
initialize() method, that's not going to work either.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090128/69d1b42d/attachment.html>

More information about the fxruby-users mailing list