After years, there is now a Ruby for Windows version that is built with the latest, stable Ruby, version 1.9.1. It is built with MinGW rather than a Microsoft C compiler. A Ruby package called Ocra can create an independent executable.
From the archive at http://www.EmpowermentZone.com/rb_fruit.zipThis fruit basket program is written in Ruby: an open source, dynamic language available at
http://ruby-lang.orgThe program uses WxWidgets: a cross-platform GUI library with Ruby bindings at
http://WxRuby.RubyForge.net A WxRuby tutorial is at http://wxruby.rubyforge.org/wiki/wiki.pl?New_TutorialThe calling syntax is made more Ruby-like by a layer of wrappers called WxSugar. The batch file, run.bat, executes the program with the Ruby interpreter for Windows, rubyw.exe.
I have done a Ruby fruit basket program before -- with assistance from Jay Macarty. Using knowledge gained since then, this one tries to be as simple, short, and readable as possible.
An update to this archive builds the program with the latest Ruby for Windows (version 1.9.1) from
http://RubyInstaller.org You can run the batch file install_ruby.bat to download the Ruby installer. By default, this version is installed in the directory C:\Ruby191Add its bin subdirectory to your Windows search path, e.g., at a command prompt as follows:
set path=C:\Ruby191\bin;%path% You can run the batch file set_path.bat to do this. Then install the following gems as follows: gem install wxruby-ruby19 gem install wx_sugar gem install ocra You can run the batch file install_gems to do this. The executable, rb_fruit.exe, is built with the following command: ocra rb_fruit.rbw You can run the batch file build.bat to do this. Jamal # Content of rb_fruit.rbw # Fruit basket program in Ruby # Public domain by Jamal Mazrui # Load Wx wrappers require "wx" require "wx_sugar" # Import Wx namespace include Wx # Define Wx application App.run do dlg = Dialog.new(nil, :title => "Fruit Basket") # Define layout grid dlg.arrange_grid( :cols => 3, :rows => 2) do dlg.add(StaticText[:label => "&Fruit:"]) txtFruit = dlg.add(TextCtrl) btnAdd = dlg.add(Button[:label => "&Add"]) btnAdd.set_default dlg.add(StaticText[:label => "&Basket:"]) lstBasket = dlg.add(ListBox) btnDelete = dlg.add(Button[:label => "&Delete"]) # Define Add event handler dlg.evt_button(btnAdd.get_id) do sFruit = txtFruit.get_value if sFruit == "" message_box("No fruit to add!", "Alert") else lstBasket.append(sFruit) iFruit = lstBasket.get_count - 1 lstBasket.set_selection(iFruit) txtFruit.clear end end # Define Delete event handler dlg.evt_button(btnDelete.get_id) do iFruit = lstBasket.get_selection if iFruit == -1 message_box("No fruit to Delete!", "Alert") else lstBasket.delete(iFruit) iFruit -= 1 if iFruit == lstBasket.get_count lstBasket.set_selection(iFruit) end end end # grid # Define Close event handler dlg.evt_close do exit if message_box("Close program?", "Confirm", YES_NO) == YES end # Activate dialog dlg.show end # app # End of rb_fruit.rbw __________View the list's information and change your settings at //www.freelists.org/list/programmingblind