rem ' form.txt (BBjFormValidationEvent)
sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
window! = sysgui!.addWindow(50,50,340,325,"BBjFormValidationEvent",$00090003$)
window!.setCallback(window!.ON_CLOSE,"eoj")
list$="";for i=asc("A") to asc("Z");list$=list$+chr(i)+$0a$;next i
gosub init; rem ' temp file + recordset
navigator! = window!.addNavigator(100,10,10,320,25,"Navigator",$$)
navigator!.setToolTipText("BBjNavigator")
navigator!.bindRecordSet(recordset!,"key")
navigator!.setCallback(navigator!.ON_NAV_FIRST,"nav_first")
navigator!.setCallback(navigator!.ON_NAV_PREVIOUS,"nav_previous")
navigator!.setCallback(navigator!.ON_NAV_NEXT,"nav_next")
navigator!.setCallback(navigator!.ON_NAV_LAST,"nav_last")
listbox! = window!.addListBox(101,10,45,100,60,list$,$$)
listbox!.setToolTipText("BBjListBox")
listbox!.bindRecordSet(recordset!,"listbox")
listbutton! = window!.addListButton(102,120,45,100,160,list$,$$)
listbutton!.setToolTipText("BBjListButton")
listbutton!.bindRecordSet(recordset!,"listbutton")
listedit! = window!.addListEdit(103,230,45,100,160,list$,$$)
listedit!.setToolTipText("BBjListEdit")
listedit!.bindRecordSet(recordset!,"listedit")
editbox! = window!.addEditBox(104,120,80,100,25,"",$$)
editbox!.setToolTipText("BBjEditBox")
editbox!.bindRecordSet(recordset!,"editbox")
password! = window!.addEditBox(105,230,80,100,25,"",$0400$)
password!.setToolTipText("BBjEditBox (Password)")
password!.bindRecordSet(recordset!,"password")
cedit! = window!.addCEdit(106,10,115,100,60,"",$8106$)
cedit!.setToolTipText("BBjCEdit")
cedit!.bindRecordSet(recordset!,"cedit")
text! = window!.addStaticText(107,10,185,100,25,"",$$)
text!.setToolTipText("BBjStaticText")
text!.bindRecordSet(recordset!,"text")
inpute! = window!.addInputE(108,120,115,100,25,$$,"XXXX-XXXX-XXXX-XXXX")
inpute!.setToolTipText("BBjInputE")
inpute!.bindRecordSet(recordset!,"inpute")
inputn! = window!.addInputN(109,120,150,100,25,$$,"$###,###,###.00-")
inputn!.setToolTipText("BBjInputN")
inputn!.bindRecordSet(recordset!,"inputn")
inputd! = window!.addInputD(110,120,185,100,25)
inputd!.setToolTipText("BBjInputD")
inputd!.bindRecordSet(recordset!,"inputd")
checkbox! = window!.addCheckBox(111,230,115,100,25,"CheckBox",$$)
checkbox!.setToolTipText("BBjCheckBox")
checkbox!.bindRecordSet(recordset!,"checkbox")
radio1! = window!.addRadioButton(112,230,150,100,25,"Radio1",$$)
radio1!.setToolTipText("BBjRadioButton")
radio1!.bindRecordSet(recordset!,"radio1")
radio1!.setCallback(radio1!.ON_CHECK_ON,"check")
radio1!.setCallback(radio1!.ON_CHECK_OFF,"check")
radio2! = window!.addRadioButton(113,230,185,100,25,"Radio2",$$)
radio2!.setToolTipText("BBjRadioButton")
radio2!.bindRecordSet(recordset!,"radio2")
radio2!.setCallback(radio2!.ON_CHECK_ON,"check")
radio2!.setCallback(radio2!.ON_CHECK_OFF,"check")
slider! = window!.addHorizontalSlider(114,10,220,320,50)
slider!.setMajorTickSpacing(10)
slider!.setMinorTickSpacing(5)
slider!.setPaintTicks(1)
slider!.setPaintLabels(1)
slider!.setToolTipText("BBjSlider")
slider!.bindRecordSet(recordset!,"slider")
form! = window!.addButton(1,10,285,150,25,"Form Validation",$$)
form!.setCallback(form!.ON_BUTTON_PUSH,"form")
form!.setCallback(form!.ON_FORM_VALIDATION,"formvalidation")
getText! = window!.addButton(2,170,285,150,25,"getText",$$)
getText!.setCallback(getText!.ON_BUTTON_PUSH,"getText")
radiogroup! = window!.addRadioGroup()
radiogroup!.add(radio1!)
radiogroup!.add(radio2!)
print recordset!.getCurrentRecordData()
for id = 101 to 114
window!.getControl(id).setCallback(window!.ON_LOST_FOCUS,"blur",err=*next)
next id
process_events
eoj:
rem ' gosub dirty
recordset!.close()
erase filename$
release
init:
filename$ = "navigator"+str(dec(info(3,0)))+".dat"
erase filename$,err=*next
vkeyed filename$,[0:1:4],0,1024
temp = unt
open (temp)filename$
template$ = "key:c(4),slider:n(3*),listbox:c(1*),listbutton:c(1*),listedit:c(1*),"
template$ = template$ + "radio1:n(1*),radio2:n(1*),checkbox:n(1*),inputn:n(9*),"
template$ = template$ + "inputd:n(7*),text:c(10*),editbox:c(10*),password:c(10*),"
template$ = template$ + "inpute:c(10*),cedit:c(99*=)"
dim rec$:template$
for rec = 1 to 100
rec.key$ = str(rec*10:"0000"); rem str(rnd(9999):"0000")
rec.slider = rnd(100)
rec.listbox$ = chr(asc("A")+rnd(26))
rec.listbutton$ = chr(asc("A")+rnd(26))
rec.listedit$ = chr(asc("A")+rnd(26))
rec.radio2 = mod(rec,2)
rec.radio1 = !(rec.radio2)
rec.checkbox = rnd(2)
rec.inputn = rnd(0) * 9999999
rec.inputd = rnd(1000) + jul(0,0,0) - 500
gosub text; rec.text$ = text$
gosub text; rec.editbox$ = text$
gosub text; rec.password$ = text$
gosub text; rec.inpute$ = text$
rec.cedit$ = ""; for x = 0 to rnd(16); gosub text; rec.cedit$ = rec.cedit$ + text$ + " " ; next x
writerecord(temp)rec$
next rec
close (temp)
recordset! = bbjapi().createFileRecordSet(filename$,"",fattr(rec$))
return
text:
text$ = ""
for i = 1 to rnd(16)
text$ = text$ + chr(asc("a")+rnd(26))
next i
return
return
check:
event! = sysgui!.getLastEvent()
control! = event!.getControl()
print control!," ",event!
return
nav_first:
gosub dirty
recordset!.first(err=*next)
print recordset!.getCurrentRecordData()
return
nav_previous:
gosub dirty
recordset!.previous(err=*next)
print recordset!.getCurrentRecordData()
return
nav_next:
gosub dirty
recordset!.next(err=*next)
print recordset!.getCurrentRecordData()
return
nav_last:
gosub dirty
recordset!.last(err=*next)
print recordset!.getCurrentRecordData()
return
dirty:
if (recordset!.isCurrentRecordDirty()) then
print recordset!.getCurrentRecordData()
i = msgbox("Save record?",4+32+256,"Record Changed")
if (i = 6) then
recordset!.update(recordset!.getCurrentRecordData())
endif
endif
return
form:
event! = sysgui!.getLastEvent()
print event!," push form button"
return
getText:
event! = sysgui!.getLastEvent()
print event!," getText"
nano = System.nanoTime()
dim text$[101:114]
text$[101] = window!.getControl(101).getText()
text$[102] = window!.getControl(102).getText()
text$[103] = window!.getControl(103).getText()
text$[104] = window!.getControl(104).getText()
text$[105] = window!.getControl(105).getText()
text$[106] = window!.getControl(106).getText()
text$[107] = window!.getControl(107).getText()
text$[108] = window!.getControl(108).getText()
text$[109] = window!.getControl(109).getText()
text$[110] = str(window!.getControl(110).getValue())
text$[111] = str(window!.getControl(111).isSelected())
text$[112] = str(window!.getControl(112).isSelected())
text$[113] = str(window!.getControl(113).isSelected())
text$[114] = str(window!.getControl(114).getValue())
nano = System.nanoTime() - nano
msec = nano / 1000000
print 'br',"getText time for 14 controls:",msec," msec.",'er'
for id = 101 to 114
print window!.getControl(id),id,": ",text$[id]
next id
return
formvalidation:
event! = sysgui!.getLastEvent()
print event!," formvalidation"
nano = System.nanoTime()
dim text$[101:114]
if map!<> null() then win! = map!.get(new Integer(0))
for id = 101 to 114
if id<>107 then text$[id] = event!.getText(window!.getControl(id))
next id
event!.accept(event!.isSelected(checkbox!))
nano = System.nanoTime() - nano
msec = nano / 1000000
print 'br',"FormValidation time for 14 controls:",msec," msec.",'er'
for id = 101 to 114
print window!.getControl(id),id,": ",text$[id]
next id
return
blur:
event! = sysgui!.getLastEvent()
print event!," ",event!.getText()," ",event!.isTemporary()
return
|