| Subject |
Re: how left() works in dbase 11 plus |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Sun, 30 May 2021 09:25:41 +0200 |
| Newsgroups |
dbase.getting-started |
On 2021/05/30 08:03, AGOSTINHO wrote:
> Dear group,
>
> If I want to test an user's input in DBASE DOS I do somethng like this
> ?left(ccode,4)
>
> I've tried it in this function but I get an error
> also need to make sure that the input are numbers only.
>
> function ENTRYFIELD4_onKey(nChar, nPosition,bShift,bControl)
> form.clients1.params['ag'] = '%'+this.value+'%'
> form.clients1.requery()
> if form.entryfield1.value.left(4)
> do something
> endif
> return
Error messages usually, but unfortunately not always, point to exactly
what is wrong. It does help though if you give us the wording of the
error message.
Set the value property of entryfield4 to Integer. This will ensure that
the only digits can be entered.
Adding '%' to the start and end of the value will automatically convert
the result to character so that the requery() will work properly.
The left() function only works with strings, not numbers. You can test
for a 4 digit number as follows.
if form.entryfield4.value > 999 and form.entryfield4.value < 10000
do something
return
At present you onKey event handler requeries and fetches a new rowset as
each digit is entered. If you are not going to "do something" until you
have entered 4 digits then the following may be a better option
function ENTRYFIELD4_onKey(nChar, nPosition,bShift,bControl)
if form.entryfield4.value > 999
form.clients1.params['ag'] = '%'+this.value+'%'
form.clients1.requery()
do something
endif
return
This will requery as soon as the 4th digit is entered. If you want to
prevent further digits from being entered then add the 'and
form.entryfield4.value < 10000' to the test or set the entryfield's
picture property to'9999'.
Mervyn.
|
|