Hitesh Shah
17th October 2007, 09:31
Sometimes either due to space constraints on form or due to functionality requirement , developer may be required to let user enter data of any domain on a string field . In such a case, it may be useful to validate the user entry as per the domain range. Preventing user enter wrong data will also prevent the storage of wrong data . Here is a code sample which lets program validate the user entered data with any domain (cdomn) range on a string field (frst) and prompt him/her the domain validation message in case of error .
field.frst:
check.input:
ret = rdi.column(tudll942.fdnm,cdomn,coffset,csize,cdept,
ctype,cflag,cdflt)
|condition Added to provide for compnr
if not isspace(cdomn) then
ret = rdi.domain(cdomn,oformat,lechar,ilchar,adjust,errmess,exprid)
if exprid <> 0 then
on case ret
case db.string:
case db.multibyte:
if not l.expr(exprid,frst) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
case db.float:
case db.double:
tmpdval = val(frst)
if not l.expr(exprid,tmpdval) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
default:
tmplval = lval(frst)
if not l.expr(exprid,tmplval) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
endcase
endif
endif
field.frst:
check.input:
ret = rdi.column(tudll942.fdnm,cdomn,coffset,csize,cdept,
ctype,cflag,cdflt)
|condition Added to provide for compnr
if not isspace(cdomn) then
ret = rdi.domain(cdomn,oformat,lechar,ilchar,adjust,errmess,exprid)
if exprid <> 0 then
on case ret
case db.string:
case db.multibyte:
if not l.expr(exprid,frst) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
case db.float:
case db.double:
tmpdval = val(frst)
if not l.expr(exprid,tmpdval) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
default:
tmplval = lval(frst)
if not l.expr(exprid,tmplval) then
if not isspace(errmess) then
set.input.error(errmess)
else
set.input.error("tudll00069",1)
endif
|("Out of range")
endif
break
endcase
endif
endif