ken bohnenkamp
9th October 2002, 23:03
I have a string field on a form that can be 10 characters long. I want to require that when a user is inputing this field that the last 6 characters of the string are numbers.

AEXX123456 is ok, AEXX12345a is not ok.

Can anyone help me with the syntax to do editing like this?

NPRao
10th October 2002, 00:33
Here is a sample-


long i
string temp(10)
for i = 5 to 10
if ( not isdigit(temp(i;1)) ) then
message("Invalid Number")
endif
endfor

jaapzwaan
10th October 2002, 10:07
Ken,

You can also set a range in the domain specification.
Go to the session "domains" and look for the field "range"
E.g. the range for the domain "packages" is defined as:

$$ in "[a-ln-np-qs-z][a-z]"

It reads as: a package consists of two lower case characters and cannot start wit an "m", "o" or "r". (these first characters might lead to confusion with starting a menu, object or report resp.)

Yours would be something like:

$$ in "....[0-9][0-9][0-9][0-9][0-9][0-9]"

WHere the "." is any character. If it should be "any letter", replace it with [a-zA-Z]

regards,
Jaap Zwaan

dbinderbr
10th October 2002, 22:59
As "all" the last six characters of the string must be numbers you also can do the following:


if not isdigit(your.string(5;6)) then
message("Error message")
endif


So, if you have any character that is not a digit in the last six, it will cause the error message to be shown.