FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Checking for valid fieldname
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Checking for valid fieldname
Posted: Thu Nov 22, 2007 06:56 AM

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

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Checking for valid fieldname
Posted: Thu Nov 22, 2007 07:35 AM

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)

Posts: 167
Joined: Thu Mar 22, 2007 11:24 AM
Checking for valid fieldname
Posted: Thu Nov 22, 2007 08:08 AM
Using charonly :

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: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Checking for valid fieldname
Posted: Thu Nov 22, 2007 11:06 AM

Otto, Frank,

Thanks for the info. I will try it.

Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite

Continue the discussion