rem 'Data-bound controls with a Standard Navigator
rem 'Obtain the instance of the BBjAPI object
let API! = BBjAPI()
rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI)"X0"
rem 'Obtain the instance of the BBjSysGui object
let SysGui! = API!.getSysGui()
rem ' Create the data file
endif LENAME$="State2.dat"
MODES$=""
TEMPLATE$="STATE:C(2),STARTSWA:C(1),NAME:C(16* = 0)"
erase FILENAME$,err=*next
mkeyed FILENAME$,[0:1:2],0,32
channel = unt
open (channel)FILENAME$
dim REC$:TEMPLATE$
rem ' Load the file with state codes and names
while 1
dread rec.state$,rec.startsWA$,rec.name$,END=*break
write record (channel)rec$
wend
close (channel)
rem ' Create the RecordSet
RecordSet! = BBJAPI().createFileRecordSet(FILENAME$,MODES$,TEMPLATE$)
rem 'Set addWindow param values
X = 20
Y = 40
WIDTH = 600
HEIGHT = 400
TITLE$="Data-bound controls sample"
rem 'Set the current context
SysGui!.setContext(0)
rem 'Create a window
Window! = SysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010002$)
Window!.addStaticText(101,50,50,100,25,"State:")
state! = Window!.addEditBox(201,100,50,40,25,"")
state!.setEditable(0)
state!.bindRecordSet(RecordSet!,"state")
staticText! = Window!.addStaticText(220, 180, 50, 100, 25, "Starts with A ?")
starts! = Window!.addEditBox(221, 300, 50, 40,25,"")
starts!.setEditable(1)
starts!.bindRecordSet(RecordSet!, "StartsWA")
checkBox! = Window!.addCheckBox(222,350,50,25,25,"starts w A")
checkBox!.setEditable(1)
checkBox!.bindRecordSet(RecordSet!,"StartsWA")
boundGrid! = Window!.addDataBoundGrid(410,50,250,200,100,$8040$)
boundGrid!.setFitToGrid(4)
boundGrid!.setEditable(1)
boundGrid!.bindRecordSet(RecordSet!)
boundGrid!.setDefaultColumnHeaders()
boundGrid!.setColumnStyle(1, boundGrid!.GRID_STYLE_CHECKED)
boundGrid!.setRowHeight(16)
boundGrid!.setCallback(boundGrid!.ON_DB_GRID_ROW_CHANGE_REQUEST, "rowChangeRequest")
Window!.addStaticText(102,50,100,100,25,"Name:")
name! = Window!.addEditBox(202,100,100,200,25,"")
name!.bindRecordSet(RecordSet!,"name")
static2! = Window!.addStaticText(333,100, 130, 200,25,"")
static2!.bindRecordSet(RecordSet!, "name")
Navigator! = Window!.addNavigator(100,50,150,250,30,"Navigator")
Navigator!.bindRecordSet(RecordSet!,"state")
Navigator!.setCallback(Navigator!.ON_NAV_FIRST,"first")
Navigator!.setCallback(Navigator!.ON_NAV_PREVIOUS,"previous")
Navigator!.setCallback(Navigator!.ON_NAV_NEXT,"next")
Navigator!.setCallback(Navigator!.ON_NAV_LAST,"last")
Window!.setCallback(Window!.ON_CLOSE,"APP_CLOSE")
process_events
first:
gosub save
RecordSet!.first()
return
previous:
gosub save
RecordSet!.previous(err=*next)
return
next:
gosub save
RecordSet!.next(err=*next)
return
last:
gosub save
RecordSet!.last()
return
save:
if (RecordSet!.isCurrentRecordDirty()) then
print 'rb',
RecordSet!.update(RecordSet!.getCurrentRecordData())
endif
return
rowChangeRequest:
gosub save
event! = sysGui!.getLastEvent()
row = event!.getRow()
col = event!.getColumn()
x = x+1
prnumber x, " moving to ", row, "," ,cols
RecordSet!.moveToRecord(row)
boundGrid!.setSelectedColumn(col)
return
APP_CLOSE:
release
DATA "AK","1","Alaska"
DATA "AL","1","Alabama"
DATA "AR","1","Arkansas"
DATA "AZ","1","Arizona"
DATA "CA","0","California"
DATA "CO","0","Colorado"
DATA "CT","0","Connecticut"
DATA "DC","0","District of Columbia"
DATA "DE","0","Delaware"
DATA "FL","0","Florida"
DATA "GA","0","Georgia"
DATA "GU","0","Guam"
DATA "HI","0","Hawaii"
DATA "IA","0","Iowa"
DATA "ID","0","Idaho"
DATA "IL","0","Illinois"
DATA "IN","0","Indiana"
DATA "KS","0","Kansas"
DATA "KY","0","Kentucky"
DATA "LA","0","Louisiana"
DATA "MA","0","Massachusetts"
DATA "MD","0","Maryland"
DATA "ME","0","Maine"
DATA "MI","0","Michigan"
DATA "MN","0","Minnesota"
DATA "MO","0","Missouri"
DATA "MS","0","Mississippi"
DATA "MT","0","Montana"
DATA "NC","0","North Carolina"
DATA "ND","0","North Dakota"
DATA "NE","0","Nebraska"
DATA "NH","0","New Hampshire"
DATA "NJ","0","New Jersey"
DATA "NM","0","New Mexico"
DATA "NV","0","Nevada"
DATA "NY","0","New York"
DATA "OH","0","Ohio"
DATA "OK","0","Oklahoma"
DATA "OR","0","Oregon"
DATA "PA","0","Pennsylvania"
DATA "PR","0","Puerto Rico"
DATA "RI","0","Rhode Island"
DATA "SC","0","South Carolina"
DATA "SD","0","South Dakota"
DATA "TN","0","Tennessee"
DATA "TX","0","Texas"
DATA "UT","0","Utah"
DATA "VA","0","Virginia"
DATA "VI","0","Virgin Islands"
DATA "VT","0","Vermont"
DATA "WA","0","Washington"
DATA "WI","0","Wisconsin"
DATA "WV","0","West Virginia"
DATA "WY","0","Wyoming"
end
|