Re: Fruit basket program in Boo

  • From: "rrdinger" <rrdinger@xxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 21 Oct 2007 07:40:12 -0700

Sorry, I meant what are the differences in the two languages not the two fruit basket examples.


Richard
----- Original Message ----- From: "inthaneelf" <inthaneelf@xxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, October 20, 2007 10:26 AM
Subject: Re: Fruit basket program in Boo


well I can send you the fbd's in both for you to compare if you would like?

the iron python one is up on the fruit basket demo site, and I have the boo one here. or you can use Jamal's link and the one on the fb site and get them yourself, besides, smile that's why there being made available, so one can compare them.

take care,
inthane
. For Blind Programming assistance, Information, Useful Programs, and Links to Jamal Mazrui's Text tutorial packages and Applications, visit me at:
http://grabbag.alacorncomputer.com
. to be able to view a simple programming project in several programming languages, visit the Fruit basket demo site at:
http://fruitbasketdemo.alacorncomputer.com

----- Original Message ----- From: "rrdinger" <rrdinger@xxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, October 20, 2007 7:31 AM
Subject: Re: Fruit basket program in Boo


How does BOO compare with Iron Python? Other than the static typing vs dynamic typing.

Richard

----- Original Message ----- From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Friday, October 19, 2007 8:22 PM
Subject: Fruit basket program in Boo


From the zip archive at
http://www.EmpowermentZone.com/boo_fruit.zip

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

Boo borrows syntax from Python, seeks to improve it, and combine strengths
of both static and dynamic languages.  Its home page is at
http://boo.codehaus.org
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
http://codeconverter.sharpdevelop.net/Convert.aspx
For comparison, the C# code is available in the file cs_fruit.cs.

Jamal

/*
content of boo_fruit.boo
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
row
// 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
self.Controls.Add(lblFruit)
self.Controls.Add(txtFruit)
self.Controls.Add(btnAdd)
self.Controls.Add(lblBasket)
self.Controls.Add(lbBasket)
self.Controls.Add(btnDelete)

// 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')
else:
lbBasket.Items.Add(sFruit)
txtFruit.Text = ''
lbBasket.SelectedIndex = (lbBasket.Items.Count -
1)
txtFruit.Focus()


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


// define main entry point of application
public static def Main():
Application.Run(MyForm())

MyForm.Main()

//End of program

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind



__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: