[fxruby-users] (no subject)

dave L dglnz at yahoo.com
Wed Jan 28 19:27:41 EST 2009


The code that you see in my original post is SUPPOSED to be the same as that which is shown in the GUIb tutorial.

Okay the file name isn't the same _but_ that shouldn't matter.

the lower case c in class was a capital but i still had the same error.


--- On Thu, 29/1/09, Lyle Johnson <lyle at lylejohnson.name> wrote:

> From: Lyle Johnson <lyle at lylejohnson.name>
> Subject: Re: [fxruby-users] (no subject)
> To: fxruby-users at rubyforge.org
> Received: Thursday, 29 January, 2009, 2:32 AM
> 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 }
> 		end
> 
> 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 call:
> 
> 	inchesX.new app
> 
> but unless the code in "inchesX.rb" contains a
> corresponding initialize() method, that's not going to
> work either._______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users


      Easy recipes for Christmas entertaining on Yahoo!Xtra Lifestyle- http://nz.lifestyle.yahoo.com/food-recipes


More information about the fxruby-users mailing list