Re: Fruit basket program in Lua

  • From: Jamal Mazrui <empower@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 7 Nov 2007 10:42:31 -0500 (EST)

Apologies -- indeed, the country of origin is Brazil not Portugal.
Jamal
On Wed, 7
Nov 2007, Marlon Brandão de Sousa wrote:

> Date: Wed, 7 Nov 2007 12:11:14 -0200
> From: Marlon Brandão de Sousa <splyt.lists@xxxxxxxxx>
> Reply-To: programmingblind@xxxxxxxxxxxxx
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: Fruit basket program in Lua
>
> only fix is that lua is a creation of puc university, in Rio de
> Janeiro, Brazil ..
> Marlon
>
> 2007/11/6, Jamal Mazrui <empower@xxxxxxxxx>:
> > From the zip archive at
> > http://www.EmpowermentZone.com/lua_fruit.zip
> >
> > This fruit basket program is written in Lua:  an open source, dynamic
> > language developed at a university in Portugal (Lua means moon in
> > Portuguese).  Designed to be lightweight and portable, Lua is written in
> > ANSI C and may be used either stand-alone or as an embedded scripting
> > language for applications.  It is often deployed as a scripting engine for
> > games or portable devices.  Mobile Speak, the screen reader for smart
> > phones, uses Lua for scripting.
> >
> > The Lua home page is at
> > http://lua.org
> >
> > The fruit basket program uses wrappers for the WxWidgets GUI library,
> > available at
> > http://WxLua.SourceForge.net
> >
> > This package includes a utility for creating a stand-alone executable that
> > runs an embedded Lua script.  A batch file included with this archive,
> > build.bat, shows how lua_fruit.exe is built.  To run the executable,
> > remember to include its .exe extension on the command line -- I found this
> > not to be optional, as is usually the case.
> >
> > If one has a C compiler, WxLua may be selectively included in an
> > executable.  Otherwise, the resulting size is large:  about 6 megabytes.
> > The executable may be reduced to a quarter of that size, however, using an
> > open source utility called Ultimate Packer for Executables, available at
> > http://upx.sourceforge.net
> >
> > The batch file invokes this utility so that lua_fruit.exe is about 1.5
> > megs.  The archive includes all components needed to rebuild the
> > executable.  Its source code is below.  I have also prepared a collection
> > of Lua documentation in structured text format at
> > http://www.EmpowermentZone.com/lua_doc.zip
> >
> > Jamal
> >
> > -- Content of the file lua_fruit.lua
> > -- Fruit basket program in Lua
> > -- Public domain by Jamal Mazrui
> >
> > dlg = wx.wxDialog(wx.NULL, wx.wxID_ANY, "Fruit Basket",
> > wx.wxDefaultPosition, wx.wxSize(513, 176))
> >
> > lblFruit = wx.wxStaticText(dlg, wx.wxID_ANY, "&Fruit:", wx.wxPoint(14,
> > 14), wx.wxDefaultSize)
> > txtFruit = wx.wxTextCtrl(dlg, wx.wxID_ANY, "", wx.wxPoint(43, 14),
> > wx.wxDefaultSize, wx.wxTE_LEFT)
> >
> > lblBasket = wx.wxStaticText(dlg, wx.wxID_ANY, "&Basket:", wx.wxPoint(251,
> > 14), wx.wxDefaultSize)
> > lstBasket = wx.wxListBox(dlg, wx.wxID_ANY, wx.wxPoint(293,14),
> > wx.wxDefaultSize, {})
> >
> > btnAdd = wx.wxButton(dlg, wx.wxID_ANY, "&Add", wx.wxPoint(190, 121),
> > wx.wxDefaultSize)
> > btnAdd:SetDefault()
> > dlg:Connect(btnAdd:GetId(), wx.wxEVT_COMMAND_BUTTON_CLICKED,
> > function(event)
> > sValue = txtFruit:GetValue()
> > if sValue == "" then
> > wx.wxMessageBox("No fruit to add!", "Alert", wx.wxICON_EXCLAMATION, dlg)
> > return
> > end
> >
> > lstBasket:Append(sValue)
> > txtFruit:Clear()
> > iCount = lstBasket:GetCount()
> > iIndex = iCount - 1
> > lstBasket:SetSelection(iIndex)
> > end)
> >
> > btnDelete = wx.wxButton(dlg, wx.wxID_ANY, "&Delete", wx.wxPoint(217, 121),
> > wx.wxDefaultSize)
> > dlg:Connect(btnDelete:GetId(), wx.wxEVT_COMMAND_BUTTON_CLICKED,
> > function(event)
> > iIndex = lstBasket:GetSelection()
> > if iIndex == -1 then
> > wx.wxMessageBox("No fruit to delete!", "Alert", wx.wxICON_EXCLAMATION,
> > dlg)
> > return
> > end
> >
> > lstBasket:Delete(iIndex)
> > iCount = lstBasket:GetCount()
> > if iIndex == iCount then
> > iIndex = iCount - 1
> > end
> >
> > lstBasket:SetSelection(iIndex)
> > end)
> >
> > dlg:Connect(wx.wxEVT_CLOSE_WINDOW,
> > function (event)
> > if wx.wxMessageBox("Exit program?", "Confirm", wx.wxYES_NO, dlg) ==
> > wx.wxYES then
> > event:Skip()
> > dlg:Destroy()
> > end
> > end)
> >
> > dlg:Centre()
> > dlg:Show(true)
> >
> > -- End of lua_fruit.lua
> >
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
> >
>
>
> --
> When you say "I wrote a program that crashed Windows," people just
> stare at you blankly and say "Hey, I got those with the system, for
> free."
> Linus Torvalds
> __________
> 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: