Fruit basket program in JScript .NET using Layout by Code
- From: Jamal Mazrui <empower@xxxxxxxxx>
- To: programmingblind@xxxxxxxxxxxxx
- Date: Tue, 04 May 2010 08:58:21 -0400
One of the samples from the archive at
http://EmpowermentZone.com/appsetup.zip
This is a fruit basket program in JScript .NET. This language is
standards-compliant JavaScript. In addition, it has nearly full access
to the .NET Framework class library.
JScript .NET is a highly dynamic language. Note, for example, that the
code below works without any declarations of data types. JScript .NET
infers type information from context whenever possible, and uses
reflection as needed. A syntax extension is available, however, for
specifying particular types. Code in HomerLbc.js and HomerJax.js often
use that syntax for increased error checking and performance.
Jamal
function OnEvent (sEvent, oSender, oArgs) {
switch(sEvent) {
case 'Closing' :
if (Lbc.DialogConfirm('Confirm', 'Exit program?', 'Y') != 'Y')
oArgs.Cancel = true
break
case 'Click' :
switch (oSender.Name) {
case 'Button_Add' :
sFruit = txtFruit.Text
if (!sFruit) return Lbc.DialogShow('Alert', 'No fruit to add!')
lstBasket.Items.Add(sFruit)
iIndex = lstBasket.Items.Count - 1
lstBasket.SelectedIndex = iIndex
txtFruit.Clear()
break
case 'MenuItem_Import_Data' :
sFile = Lbc.DialogOpenFile('Import')
if (!sFile) return
dlg.Import(sFile)
break
case 'MenuItem_Export_Data' :
sFile = Lbc.DialogSaveFile('Export')
if (!sFile) return
dlg.Export(sFile)
break
case 'MenuItem_About' :
Lbc.DialogShow('Fruit Basket Sample', 'This sample uses the InJs
interpreter and the JScript .NET language\nBy Jamal Mazrui')
break
case 'MenuItem_Delete_Fruit' :
case 'Button_Delete' :
iIndex = lstBasket.SelectedIndex
if (iIndex == -1) return Lbc.DialogShow('Alert', 'No fruit to delete!')
lstBasket.Items.RemoveAt(iIndex)
iCount = lstBasket.Items.Count
if (!iCount) return
if (iIndex == iCount) iIndex --
lstBasket.SelectedIndex = iIndex
}
}
} // OnEvent function
dFocusStatus = new Hashtable()
dFocusStatus.Add('TextBox_Fruit', 'Type a fruit name and press Alt+A or
Enter to add it to the basket')
dFocusStatus.Add('Button_Add', 'Press Enter or Space to add a fruit to
the basket')
dFocusStatus.Add('ListBox_Basket', 'Use arrow keys to navigate the basket')
dFocusStatus.Add('Button_Delete', 'Press Enter or Space to delete a
fruit from the basket. Alt+D or Delete works from anywhere.')
dlg = new LbcForm('Fruit Basket', null, dFocusStatus)
dlg.AddMenu('Transfer')
dlg.AddMenuItem('Import Data', 'Control+I')
dlg.AddMenuItem('Export Data', 'Control+E')
dlg.AddMenu('Edit')
dlg.AddMenuItem('Delete Fruit', 'Delete')
dlg.AddMenu('Help')
dlg.AddMenuItem('About')
txtFruit = dlg.AddInputBox('Fruit')
btnAdd = dlg.AddButton('Add')
dlg.AcceptButton = btnAdd
dlg.AddBand()
lstBasket = dlg.AddPickBox('Basket')
btnDelete = dlg.AddButton('Delete')
dlg.CompleteDialog()
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind
Other related posts:
- » Fruit basket program in JScript .NET using Layout by Code - Jamal Mazrui