okay now that i''ve got GUIb running time to play :) Issue i now have is the 1st example in the online tutorial troubling version 2 where we separate code from the generated code of GUIb. 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) dave at AMD3000:/spare/foxgui$ I have just tried as an experiment adding inchesX:: in front of the Widget names (eg inchesX::cmLabel...) but still no joy!! have also tried adding a require fox16 above the require inchesX wit no joy. pointers please. dave. Easy recipes for Christmas entertaining on Yahoo!Xtra Lifestyle- http://nz.lifestyle.yahoo.com/food-recipes -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090128/62510cf5/attachment.html>
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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090128/69d1b42d/attachment.html>
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>
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-usersEasy recipes for Christmas entertaining on Yahoo!Xtra Lifestyle- http://nz.lifestyle.yahoo.com/food-recipes