_Ralph_
16th October 2008, 18:40
Hi everyone!

I have a string field that in some situations must only have values of numbers or letters

In other words symbols like <>:^}?/. should be avoided.

I take a look at some tccom dlls and other tools functions but what I could resolve it´s just half of the problem.

For number checks i'm using isigit().

But what about the symbols(@#$%¨&*())

any help will be appreciated
.

shah_bs
16th October 2008, 18:49
Is the field just a program variable or is it going to be a field in a table?

If it is a field in a table, you can define a new domain to use with the field (using Maintain Domains) - in this (in BAAN IV), on Form 3, there is facility to specify "Illegal Chars.". This will prevent entry of any illegal characters you have defined, when the data is entered in the field using a normal BAAN session.

If it is a program variable, you will have to write your own library function to validate.

zardoz
16th October 2008, 21:16
Something like this:


function long check.string(ref string str)
{
long i
#define ALLOWED_CHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

for i = 1 to len(str)
if not pos(str(i;1), ALLOWED_CHARS) then
return(FALSE)
endif
endfor
return(TRUE)
}

_Ralph_
17th October 2008, 00:15
thank you for the help.

Unfortunately until where we know tools does not a function for that as I see.

Here is the solution I used. As the field just accept caps Letters I prefer to make use of the ASC table as you can see


long cont
long asc.code

while(cont <= len(my.string))
if not isdigit(my.string(cont;1)) then
asc.code.o = asc(my.string(cont;1))
| < A or > Z
if asc.code.o < 65 or asc.code.o > 90 then
return(false)
endif
endif
cont = cont + 1
endwhile
return(true)


Thanks for the replies again!

Hitesh Shah
17th October 2008, 07:37
U can either use expr.compile or use domain tutrg.path which has range expression like

$$ in "^[-a-zA-Z0-9~_%^.+=/\\${}#]* *$" or $$ in "^[a-zA-Z]:[-a-zA-Z0-9~_%^.+=/\\${}#]* *$"

Dont know if this suffice ur requirement .

I think this has proper escape mechanisms for special characters ( there are minor changes in certain porting sets wrt to special characters ). So u need to test it for u .