Data aware forms for non-standard databases

Though the Forms Designer table list is only available for the native KCML database, data aware forms can be used with any database by defining suitable field variables.

Here is an example program showing binding from a static buffer.

DIM row$100, N=5, count, ethis, x
DIM n$(N)30, salary(N), eenum(N)
DIM .name$=(1, 30), .salary=(31, "B4"), .eenum=(35, "B2")
count = 0
WHILE count <= N DO
READ x
IF (x == 0) THEN BREAK
eenum(++count) = x
READ n$(count), salary(count)
WEND
- DEFFORM SalForm()={.form,.form$,.Style=0x50c000c4,.Width=259,.Height=156,.text$="Employee database",.Id=1024},{.ok,.button$,.Style=0x50010001,.Left=203,.Top=6,.Width=50,.Height=14,.text$="OK",.__Anchor=5,.Id=1},\
{.cancel,.button$,.Style=0x50010000,.Left=203,.Top=23,.Width=50,.Height=14,.text$="Cancel",.__Anchor=5,.Id=2},\
{.editgroup1,.EditGroup$,.Left=10,.Top=20,.Width=187,.Height=127,.Id=1000},\
{.editControl1,.kcmldbedit$,.Style=0x50810080,.Left=107,.Top=36,.Width=45,.Height=15,.Id=1001,.ReadOnly=1,.DataSource=row$,.DataField=.eenum,.EditGroup=.editgroup1,.label$="Employee:"},\
{.editControl2,.kcmldbedit$,.Style=0x50810080,.Left=67,.Top=66,.Width=122,.Height=15,.Id=1002,.ReadOnly=1,.DataSource=row$,.DataField=.name$,.DBEnabled=1,.EditGroup=.editgroup1,.label$="name:"},\
{.editControl3,.kcmldbedit$,.Style=0x50810080,.Left=102,.Top=96,.Width=53,.Height=15,.Id=1003,.ReadOnly=1,.DataSource=row$,.DataField=.salary,.DBEnabled=1,.EditGroup=.editgroup1,.label$="Salary:"},\
{.cmdPrev,.button$,.Style=0x50010000,.Left=209,.Top=87,.Width=43,.Height=15,.text$="prev",.Id=1004,.Click()},\
{.cmdNext,.button$,.Style=0x50010000,.Left=209,.Top=107,.Width=43,.Height=15,.text$="next",.Id=1005,.Click()},\
{.cmdFirst,.button$,.Style=0x50010000,.Left=209,.Top=68,.Width=43,.Height=15,.text$="first",.Id=1006,.Click()},\
{.cmdLast,.button$,.Style=0x50010000,.Left=209,.Top=127,.Width=43,.Height=15,.text$="last",.Id=1007,.Click()}
+ DEFEVENT SalForm.Enter()
'GetEmployee(1)
END EVENT
+ DEFEVENT SalForm.cmdPrev.Click()
'GetEmployee(--ethis)
END EVENT
+ DEFEVENT SalForm.cmdNext.Click()
'GetEmployee(++ethis)
END EVENT
+ DEFEVENT SalForm.cmdFirst.Click()
'GetEmployee(1)
END EVENT
+ DEFEVENT SalForm.cmdLast.Click()
'GetEmployee(count)
END EVENT
FORM END SalForm
SalForm.Open()
END
DEFSUB 'GetEmployee(e)
REM populate row buffer from the database
IF (e > 0 AND e <= count)
FLD(row$.eenum) = eenum(e)
FLD(row$.name$) = n$(e)
FLD(row$.salary) = salary(e)
ethis = e
END IF
END SUB
REM some employees
DATA 1, "Alan", 10000
DATA 2, "Betty", 20000
DATA 3, "Charlie", 30000
DATA 4, "Dorothy", 20000
DATA 8, "Edward", 14000
DATA 0