[fxruby-users] (no subject)

Meinrad Recheis meinrad.recheis at gmail.com
Wed Jan 28 14:42:41 EST 2009


On Wed, Jan 28, 2009 at 2:32 PM, Lyle Johnson <lyle at lylejohnson.name> wrote:

>
> 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.
>

yes it will, because the initialize method is defined in the source file
generated by foxGUIb. this example in the users guide is about keeping
manual additions separated from generated code in order to be able to
re-generate it.

-- henon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090128/2d91c63e/attachment-0001.html>


More information about the fxruby-users mailing list