require "phi"
require "rdb/rdb"
require "rdb/dbx"

form = Phi::Form.new
grid = Phi::DBGrid.new form
grid.align = Phi::AL_CLIENT

connection = Phi::SQLConnection.new 'sqlitetest'
data_set = Phi::SQLDataSet.new connection
provider = Phi::DataSetProvider.new data_set
#provider.name = 'DataSetProvider1'

c = Phi::ClientDataSet.new
#c.provider_name = 'DataSetProvider1'
c.set_provider provider

data_set.command_text = <<EOT
  select * from Simpsons
EOT
c.open

data_source = Phi::DataSource.new c

c.after_scroll = proc {
  print 'Simpsons.LastName=',c['Simpsons.LastName'],', Simpsons.FirstName=',c['Simpsons.FirstName'],"\n"
}

grid.data_source = data_source
form.show
Phi.mainloop
