KCML has two single-line edit controls: the basic .edit$
Win32 edit, and .kcmldbedit$, a database-aware
edit/combobox hybrid. This example puts one of each on a form and shows how to
read, write, and validate their values.
![Two edit controls (.edit$ and .kcmldbedit$) seeded with hello/world, with a read-back showing edt1=[hello] kedt1=[world].](images/edit-demo.png)
Verified by execution on KCML 06.00.88 (KClient direct mode).
.Text$ for both .edit$ and .kcmldbedit$.Enter() event.Validate() event, whose ValidateText$ holds the proposed new value.Help$ — shown in the status bar while the control has focus.01000 REM test_edit - .edit$ and .kcmldbedit$ side by side
: DIM result, msg$120
01010 - DEFFORM EditTest()=\
{.form,.form$,.Style=0x50c000c4,.Width=380,.Height=200,.Text$="Edit Test",.Id=1024},\
{.lblE1,.static$,.Style=0x50000000,.Left=10,.Top=14,.Width=80,.Height=10,.Text$=".edit$",.Id=2000,.Font=.SegoeCtl},\
{.edt1,.edit$,.Style=0x50810080,.Left=100,.Top=12,.Width=180,.Height=13,.Id=2001,.Help$="Basic edit control",.Font=.SegoeCtl},\
{.lblE2,.static$,.Style=0x50000000,.Left=10,.Top=34,.Width=80,.Height=10,.Text$=".kcmldbedit$",.Id=2002,.Font=.SegoeCtl},\
{.kedt1,.kcmldbedit$,.Style=0x50810080,.Left=100,.Top=32,.Width=180,.Height=13,.Id=2003,.Help$="DB-aware edit (combobox/edit hybrid)",.Font=.SegoeCtl},\
{.btnRead,.button$,.Style=0x50010000,.Left=10,.Top=60,.Width=120,.Height=14,.Text$="Read both values",.Id=2010,.Font=.SegoeCtl},\
{.btnSet,.button$,.Style=0x50010000,.Left=140,.Top=60,.Width=120,.Height=14,.Text$="Set sample text",.Id=2011,.Font=.SegoeCtl},\
{.lblShow,.static$,.Style=0x50000000,.Left=10,.Top=85,.Width=360,.Height=10,.Text$="(no read yet)",.Id=2020,.Font=.SegoeCtl},\
{.btnClose,.button$,.Style=0x50010001,.Left=290,.Top=155,.Width=80,.Height=14,.Text$="Close",.Id=1,.Font=.SegoeCtl},\
{.paneStatus,.status$,.Width=380,.Style=0x50000000,.Text$="Ready"},\
{.SegoeCtl,.dlgfont$,.Name$="Segoe UI",.Size=10}
: + DEFEVENT EditTest.Enter()
: .edt1.Text$ = "hello"
: .kedt1.Text$ = "world"
: END EVENT
: + DEFEVENT EditTest.btnRead.Click()
: msg$ = $PRINTF("edt1=[%s] kedt1=[%s]", RTRIM(.edt1.Text$), RTRIM(.kedt1.Text$))
: .lblShow.Text$ = msg$
: END EVENT
: + DEFEVENT EditTest.edt1.Validate()
: .lblShow.Text$ = $PRINTF("edt1.Validate - new=[%s]", RTRIM(ValidateText$))
: END EVENT
: FORM END EditTest
01020 result = EditTest.Open()
: $END
Reading and writing. Both controls expose .Text$. Because KCML strings are
fixed-length and space-padded, wrap reads in RTRIM() to drop trailing spaces.
Validation. The Validate() event fires as the user leaves the field. The
proposed value arrives in the special variable ValidateText$ — inspect it,
and reject the change if needed, before it is committed to .Text$.
.edit$ vs .kcmldbedit$. Use .edit$ for plain text input. Use
.kcmldbedit$ when you want the data-aware features: an optional dropdown list
(.Add(text$, tag$)), KISAM data binding, and the extra Change() / Return()
/ DropDown() events. The DEFFORM token is .kcmldbedit$ — .KCMLedit$ is not
valid despite appearing in some older docs.