find a word in a field of a dbf file

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

find a word in a field of a dbf file

Post by fouednoomen »

Hello everyone, can someone help me,
how can I look for a character string example "name of the road" in a field address of a dbf file.
how can i use a index recherche
many thanks
User avatar
serge_girard
Posts: 3166
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: find a word in a field of a dbf file

Post by serge_girard »

How many records in your DBF?
If less than 10.000 I would do something like this:

Code: Select all

 
aFOUND := {}
DO WHILE .NOT. EOF() 
   IF 'someting' $ dbffield1 .OR.   'someting' $ dbffield2 // ETC....
      AADD(aFOUND, RECNO()) 
    ENDIF
    SKIP
ENDDO      
CLOSE ALL

FOR A = 1 TO LEN(aFOUND)
   ? aFOUND [A]
NEXT
 
Serge
There's nothing you can do that can't be done...
User avatar
gfilatov
Posts: 1067
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: find a word in a field of a dbf file

Post by gfilatov »

fouednoomen wrote: Wed Sep 25, 2019 9:48 am how can I look for a character string example "name of the road" in a field address of a dbf file.
how can i use a index recherche
Hello,

Please take a look for a discussion at
http://hmgforum.com/viewtopic.php?f=13& ... eek#p58881

HTH :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
dragancesu
Posts: 921
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: find a word in a field of a dbf file

Post by dragancesu »

Maybe finction AT() help you

*** we found string 'something'

SET FILTER TO AT( 'someting', dbffield ) > 0
dbgotop()

p.s. this solution is not optimal but is easy
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: find a word in a field of a dbf file

Post by fouednoomen »

Many thanks for all
franco
Posts: 821
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: find a word in a field of a dbf file

Post by franco »

I use
temp = "temp"
index on address to temp for "somestreet" $ address
browse ???
set index to
temp := alltrim(temp)+".ntx"
erase (temp)
Franco
All The Best,
Franco
Canada
User avatar
SALINETAS24
Posts: 667
Joined: Tue Feb 27, 2018 3:06 am
DBs Used: DBF
Contact:

Re: find a word in a field of a dbf file

Post by SALINETAS24 »

Hola, muy buena idea.
dragancesu wrote: Wed Sep 25, 2019 12:39 pm Maybe finction AT() help you

*** we found string 'something'

SET FILTER TO AT( 'someting', dbffield ) > 0
dbgotop()

p.s. this solution is not optimal but is easy

Yo utilizo esta forma lo aplico sobre el BROWSE activo, y funciona muy bien.

Code: Select all

(_cArea)->( dbSetFilter( {|| AT(xCadena,_cArea->Campo)> 0 },"AT(xCadena,_cArea->Campo)> 0"   ) )
_cArea : Alias de la DBF
xCadena : lo que quiero buscar
_cArea->Campo : Es el Campo de la DBF donde quiero saber si exite la xCadena

y me selecciona aquellos registros que devuelvan un valor mayor que cero

Saludos a todos y vamos con una cervecita
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no. :shock:
Post Reply