[fxruby-users] trouble with program code separation

dave L dglnz at yahoo.com
Mon Jun 29 18:14:07 EDT 2009


Henon,

Just looking at the code snippet below and want to ask if i should have everything in sqlite3_calls.rb wrapped in a init define as that's what got my 1st sample program working from the user guide.

e.g.

module Dbase
  def init
    # original code put in here
  end

end

rgds,

dave.

--- On Tue, 30/6/09, Meinrad Recheis <meinrad.recheis at gmail.com> wrote:

> From: Meinrad Recheis <meinrad.recheis at gmail.com>
> Subject: Re: [fxruby-users] trouble with program code separation
> To: fxruby-users at rubyforge.org
> Received: Tuesday, 30 June, 2009, 2:22 AM
> hi dave, at db is nil at the time
> rec_to_find is called. make sure it is initialized
> correctly.-- henon
> 
> On Mon, Jun 29, 2009 at 12:20 PM,
> dave L <dglnz at yahoo.com>
> wrote:
> 
> Help,
> 
> I have a foxGUI gernerated file named monitorwindow and a
> ruby file called sqlite3_calls.rb
> 
> 
> I want to have my monitorwindow make calls to
> sqlite3_calls.rb and pass through parameters to it so i can
> get data to display to the screen.
> 
> I have tried making the code (which currently has only ONE
> method in it called rec_to_find) a class and a
> module but cannot get the link to work.
> 
> 
> based on the success i had with example ONE of the user
> guide ( although it only used a mouse click) i get this
> error.
> 
> /sqlite3_calls.rb:18:in `rec_to_find': undefined method
> `execute' for nil:NilClass (NoMethodError)
> 
>     from monitorscreen.rbw:65:in
> `construct_widget_tree'
>     from
> 
> C:/Ruby1.8/lib/ruby/gems/1.8/gems/fxruby-1.6.16-x86-mswin32-60/lib/fox16/responder2.rb:55:in
> `call'
>     from
> C:/Ruby1.8/lib/ruby/gems/1.8/gems/fxruby-1.6.16-x86-mswin32-60/lib/fox16/responder2.rb:55:in
> `onHandleMsg'
> 
>     from monitorscreen.rbw:206:in `run'
>     from monitorscreen.rbw:206
> >Exit code: 1
> 
> here is the code in sqlite3_calls.rb - as a
> ruby program this works - well as a definition of class it
> does.
> 
> 
> require 'sqlite3.rb'
> 
> module Dbase   
>   def initialize
>     @db = SQLite3::Database.new( "customer" )
>  end
>  
>  def rec_to_find(table, colname, tofind)
>   stmt = "select cust_nos, caddress, cname, contact,
> notes, on_stop, phone_nos from #{table} where #{colname} =
> ?"
> 
>   row = @db.execute(stmt,tofind) # this is the line
> it's borking on - why??
>     @rec
>  = []    
>    row.each do|fld|           
>      @rec = fld
>    end   
>    return @rec   
>  end
> end
> 
> I ahve tried using :: insetad of the fullstop but i get the
> same error!!
> 
> also tried having the require sqlite3.rb in the file below
> but it fails there too - same error.
> 
> here is some of the code from the mainscreen.rb file.
> 
> # source generated by foxGUIb 1.0.0
> require 'sqlite3_calls.rb'
> 
> class MainWindow
>   
>     def initialize( parent)   
>         extend Dbase    
> 
>         @mydb = Dbase
>         construct_widget_tree( parent)
>         init if respond_to? 'init'
>     end
>    
>  
>     def construct_widget_tree( parent)
> 
> code I've inserted to get the customer data returned.
> 
> row = rec_to_find('customer', 'cust_nos',
> @dice_code.text) 
> 
> any help would be appreciated.
> 
> 
> dave.
> 
> 
> 
> 
>       Need mail bonding? Bring all your contacts to
> Yahoo!Xtra with TrueSwitch
> 
> _______________________________________________
> 
> fxruby-users mailing list
> 
> fxruby-users at rubyforge.org
> 
> http://rubyforge.org/mailman/listinfo/fxruby-users
> 
> 
> 
> -- 
> --
> Git# -->
> Git for .NET
> 
> 
> 
> 
> 
> 
> 
> -----Inline Attachment Follows-----
> 
> _______________________________________________
> fxruby-users mailing list
> fxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/fxruby-users


      


More information about the fxruby-users mailing list