Re: Fruit basket program in Boo

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 20 Oct 2007 09:39:08 +0300

Well, I'd say that this language also borrows the disadvantages of python and the disadvantages of C#.

It is harder to use by a blind because of its python style without punctuation signs, it requires same much code as C#, and it is not portable.

If Windows need to be the target platform, I think C# is much better for creating such a program.


----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, October 20, 2007 6:22 AM
Subject: Fruit basket program in Boo

From the zip archive at

This fruit basket program is written in Boo  -- Full source code in the
zip archive and pasted below.  The batch file compile.bat invokes the
command-line compiler for this scripting language.  The resulting
executable, boo_fruit.exe, is about 12K in size.  No other files are
needed to run the program -- as long as the .NET Framework 2.0 is

Boo borrows syntax from Python, seeks to improve it, and combine strengths
of both static and dynamic languages.  Its home page is at
Boo resources, including the interpreter, compiler, documentation, and
examples are available from there.

I am still learning Boo, but was able to produce a working program by
converting the first C# fruit basket program I did via a web form
available at
For comparison, the C# code is available in the file cs_fruit.cs.


content of
Fruit Basket program in Boo
Public domain by Jamal Mazrui

namespace MyNamespace

import System.Windows.Forms

// define class inherited from Form
public class MyForm(System.Windows.Forms.Form):

private lblFruit as Label

private txtFruit as TextBox

private lblBasket as Label

private lbBasket as ListBox

private btnAdd as Button

private btnDelete as Button

public def constructor():
// define constructor
// set window title
self.Text = 'Fruit Basket'
//this.Width = 328;
self.Width = 400
self.Height = 285

// create two rows of controls with three controls in each
// label, textbox, button and label, listbox, button
lblFruit = Label()
lblFruit.Text = '&Fruit:'
lblFruit.Left = 14
lblFruit.Top = 14
lblFruit.Width = 44
lblFruit.Height = 16

txtFruit = TextBox()
txtFruit.Left = 64
txtFruit.Top = 14
txtFruit.Width = 200
txtFruit.Height = 16

btnAdd = Button()
btnAdd.Text = '&Add'
btnAdd.Left = 272
btnAdd.Top = 14
btnAdd.Width = 100
btnAdd.Height = 20
//  make it the default button
self.AcceptButton = btnAdd
btnAdd.Click += self.OnAddClick

lblBasket = Label()
lblBasket.Text = '&Basket:'
lblBasket.Left = 14
lblBasket.Top = 38
lblBasket.Width = 44
lblBasket.Height = 16

lbBasket = ListBox()
lbBasket.Left = 64
lbBasket.Top = 38
lbBasket.Width = 200
lbBasket.Height = 200

btnDelete = Button()
btnDelete.Text = '&Delete'
btnDelete.Left = 272
btnDelete.Top = 38
btnDelete.Width = 100
btnDelete.Height = 20
btnDelete.Click += self.OnDeleteClick

// add controls to form

// center form on screen
self.StartPosition = FormStartPosition.CenterScreen

// define event handlers for add and delete buttons
protected def OnAddClick(sender as object, e as System.EventArgs):
sFruit as string
sFruit = txtFruit.Text
if sFruit == '':
MessageBox.Show('No fruit to add.', 'Alert')
txtFruit.Text = ''
lbBasket.SelectedIndex = (lbBasket.Items.Count -

protected def OnDeleteClick(sender as object, e as
iFruit as int
iFruit = lbBasket.SelectedIndex
if iFruit == (-1):
MessageBox.Show('No fruit to delete.', 'Alert')
if iFruit > (lbBasket.Items.Count - 1):
iFruit = (lbBasket.Items.Count - 1)
lbBasket.SelectedIndex = iFruit

// define main entry point of application
public static def Main():


//End of program

View the list's information and change your settings at

View the list's information and change your settings at //

Other related posts: