Hi,
My program import data from an other system. These files include a parameter and info about this parameter. When I import it I create a fieldname with the same name as the parameter from the imported file. Till now I had no problem but a client wanted to import a file that contains wrong info. My program wanted to create a fieldname containing '*' and other strange characters. Is there a way to chech if a fieldname is correct?
Thanks,
Marc
Checking for valid fieldname
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Maybe this func could help you.
Regards,
Otto
func f_isOK(cTest)
local cReturn:=""
local i:=0
FOR I := 1 TO len(cTestl)
IF ASC(substr(cTest,i,1)) >= 33 .and. ASC(substr(cTest,i,1)) <= 90
cReturn:=cReturn+substr(cTest,i,1)
elseif ASC(substr(cTest,i,1)) >= 97 .and. ASC(substr(cTest,i,1)) <= 122
cReturn:=cReturn+substr(cTest,i,1)
elseif ...
ENDIF
NEXT
return (cReturn)
Regards,
Otto
func f_isOK(cTest)
local cReturn:=""
local i:=0
FOR I := 1 TO len(cTestl)
IF ASC(substr(cTest,i,1)) >= 33 .and. ASC(substr(cTest,i,1)) <= 90
cReturn:=cReturn+substr(cTest,i,1)
elseif ASC(substr(cTest,i,1)) >= 97 .and. ASC(substr(cTest,i,1)) <= 122
cReturn:=cReturn+substr(cTest,i,1)
elseif ...
ENDIF
NEXT
return (cReturn)
-
- Posts: 167
- Joined: Thu Mar 22, 2007 11:24 am
Using charonly :
Code: Select all
LOCAL CharAllowed := "" , i , lOk
FOR i := 65 TO 90
CharAllowed += CHR(i) + CHR(i+32)
NEXT
// Are numbers allowed in fieldnames ? If yes add the range 48-57
lOk := ( LEN(CharOnly(CharAllowed,cString) == LEN(cString) )
RETURN lOk // Or CharOnly(CharAllowed,cString)
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact: