Hola Amigos :
les adjunto un pequeño proyecto en el cual muestro un problema que tengo con la funcion Ordwildseek .
El problema consiste en que no encuentra la coincidencia con el primer registro .
Por ejemplo en el proyecto que les adjunto las base de datos ordenada por nombre :
ARTICULO 1
ARTICULO 2
ARTICULO 3
ARTICULO 4
ARTICULO 10
Si coloco como busqueda "1" solo me encuentra ARTICULO 10 cuando me deberia encontrar tambien ARTICULO 1
No se si estoy cometiendo algun error en los parametros de la funcion , si coloco como segundo parametro de la misma .F. directamente el programa se cuelga .
Espero que puedan ayudarme a solucionarlo
Saludos cordiales
Mario Mansilla
Hello friends :
I attached a small project in which I show a problem that I have with the Ordwildseek function.
The problem is that it does not match the first record.
For example in the project that I attach the databases sorted by name:
ARTICLE 1
ARTICLE 2
ARTICLE 3
ARTICLE 4
ARTICLE 10
If I put as search "1" only I find ARTICLE 10 when I should also find ARTICLE 1
I do not know if I am making a mistake in the parameters of the function, if I place it as the second parameter of it .F. directly the program crashes.
I hope you can help me solve it
Best regards
Mario Mansilla
Consulta Ordwildseek
Moderator: Rathinagiri
-
- Posts: 269
- Joined: Wed Aug 13, 2008 2:35 pm
- Location: Córdoba - Argentina
Consulta Ordwildseek
- Attachments
-
- Ordwildseek.rar
- (1.26 MiB) Downloaded 234 times
- danielmaximiliano
- Posts: 2612
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: Consulta Ordwildseek
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
Re: Consulta Ordwildseek
Hello Mario,
Please be so kind to try the following updated function:
Hope that helps
Please be so kind to try the following updated function:
Code: Select all
*--------------------
Static Procedure Buscar
*--------------------
Local cBusca := "*" + AllTrim(Main.Text_1.Value) + "*"
Use Articulo
Articulo->(DbSetOrder(1))
Articulo->(DbGoTop())
DELETE ITEM ALL FROM Grid_1 OF Main
If !Empty(Main.Text_1.Value)
If AllTrim(Main.Text_1.Value) $ Articulo->NOMBRE
ADD ITEM { Codigo , Codigo , Nombre } TO Grid_1 OF Main
Endif
Do While Articulo->(OrdWildSeek( cBusca , .T. ))
ADD ITEM { Codigo , Codigo , Nombre } TO Grid_1 OF Main
EndDo
Endif
Close Articulo
Main.Grid_1.Value := Main.Grid_1.ItemCount
Main.Grid_1.Setfocus
Return
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Consulta Ordwildseek
Hi,
Although the code posted by Grigory should work, I think the logic of using ordWildSeek() goes like this:
The 1st time, you invoke the function without the second argument set, to check if you have at least one hit (i.e., a matching record).
and if succeed , you use the function in a loop with second argument (`<lContinue>`) set to .T., in order to locate all the rest matching keys, if any.
So, the `Buscar` procedure might shaped as follow:
HTH,
regards,
Pete
Although the code posted by Grigory should work, I think the logic of using ordWildSeek() goes like this:
The 1st time, you invoke the function without the second argument set, to check if you have at least one hit (i.e., a matching record).
and if succeed , you use the function in a loop with second argument (`<lContinue>`) set to .T., in order to locate all the rest matching keys, if any.
So, the `Buscar` procedure might shaped as follow:
Code: Select all
*--------------------
Static Procedure Buscar
*--------------------
Local cBusca := "*" + AllTrim(Main.Text_1.Value) + "*"
Use Articulo
Articulo->(DbSetOrder(1))
Articulo->(DbGoTop())
DELETE ITEM ALL FROM Grid_1 OF Main
If !Empty(Main.Text_1.Value)
IF Articulo->( OrdWildSeek( cBusca ) ) // 1st time call
ADD ITEM { Codigo , Codigo , Nombre } TO Grid_1 OF Main
Do While Articulo->(OrdWildSeek( cBusca , .T. )) // repeated call with .T.
ADD ITEM { Codigo , Codigo , Nombre } TO Grid_1 OF Main
EndDo
ENDIF
Endif
Main.Grid_1.Value := Main.Grid_1.ItemCount
Main.Grid_1.Setfocus
Return
regards,
Pete