[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Foxruby codes clarification please!

Mohsen Akhavan

1/16/2006 5:52:00 AM

Hello this is a ruby example that present a

list of customers form external source

(customer.rb) in a fox ruby tutorials:
require 'rubygems'
require_gem 'fxruby'
require 'customer'

include Fox

class ClipMainWindow < FXMainWindow
def initialize(anApp)
# Initialize base class first
super(anApp, "Clipboard Example", nil,

nil, DECOR_ALL, 0, 0, 400, 300)

# Place the list in a sunken frame
sunkenFrame = FXVerticalFrame.new(self,

LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME

_THICK,
0, 0, 0, 0, 0, 0, 0, 0)

# Customer list
customerList = FXList.new(sunkenFrame,

nil, 0,

LIST_BROWSESELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
$customers.each do |customer|
customerList.appendItem(customer.name,

nil, customer)
end
end

def create
super
show(PLACEMENT_SCREEN)
end
end

if __FILE__ == $0
FXApp.new("ClipboardExample", "FXRuby") do

|theApp|
ClipMainWindow.new(theApp)
theApp.create
theApp.run
end
end

and this is customer.rb:
# customer.rb

Customer = Struct.new("Customer", :name,

:address, :zip)

$customers = []
$customers << Customer.new("Reed Richards",

"123 Maple, Central City, NY", 010111)
$customers << Customer.new("Sue Storm", "123

Maple, Anytown, NC", 12345)
$customers << Customer.new("Benjamin J.

Grimm", "123 Maple, Anytown, NC", 12345)
$customers << Customer.new("Johnny Storm",

"123 Maple, Anytown, NC", 12345)

I have two question what does this part of the

codes actualy do?
def create
super
show(PLACEMENT_SCREEN)
end
end

and second what does this part of the codes

do?
if __FILE__ == $0
FXApp.new("ClipboardExample", "FXRuby") do

|theApp|
ClipMainWindow.new(theApp)
theApp.create
theApp.run
end
end
sincerely yours Mohsena


--
Posted via http://www.ruby-....