[fxruby-users] trouble with program code separation

dave L dglnz at yahoo.com
Mon Jun 29 06:20:17 EDT 2009


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" )
 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
   return @rec   

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20090629/477faecc/attachment.html>

More information about the fxruby-users mailing list