BUSQUEDA FILTRADA

HMG en Español

Moderator: Rathinagiri

User avatar
LOUIS
Posts: 256
Joined: Tue Dec 11, 2012 9:05 pm
DBs Used: DBF

BUSQUEDA FILTRADA

Post by LOUIS »

Estimados Amigos:

Aquí estoy con otra inquietud, que no logro solucionar :oops:
En una tabla de productos para vender, hay infinidad de items, y se pide hacer una lista sólo de ciertos productos que tengan una característica especial en su descripción o nombre ... esta característica no tiene una ubicación fija, puede estar al comienzo, en medio o al final del nombre ... les adjunto las imágenes que muestran la tabla con los productos y luego la pantalla del programa donde pide buscar y lo que muestra, claro que aquí está completa porque aun no sé la solución, sin embargo está señalado lo único que debe mostrar.
La programación está en clipper puro, es decir por ahí podrían dar la solución, o si lo hacen vía hmg puro, recordad que Yo estoy usando la versión 3.0.46 (así me recomendó Mr. Pablo César que siempre lo diga)

Code: Select all

#include "hmg.ch"
#include "inkey.ch"
#include 'hbclass.ch'
#include 'common.ch'
#include 'color.ch'
#include 'dll.ch'
#include 'error.ch'

REQUEST HB_GT_WIN_DEFAULT

USE TABLA		&& PRODUCTOS PARA VENDER
INDEX ON NOMBRE TO N
SET COLO TO W+*/B+
CLEA
DATO=SPACE(12)
@ 2,10 SAY 'DIGITE ALGUNA PISTA DEL PRODUCTO A BUSCAR ...' GET DATO VALID !EMPT(DATO)
READ
L=4
DO WHILE .NOT. EOF()
   @ L,10 SAY BODEGA+' '+NOMBRE+STR(STOCK)
   L=L+1
   SKIP
ENDDO
L=L+1
@ L-1,10-2 TO L+1,64
@ L,10 SAY '*** FIN DE BUSQUEDA ... PULSE UNA TECLA PARA SALIR ***'
INKEY(0)
CLOS ALL
RETU
De antemano muchas gracias.
Attachments
PROGRAMA.jpg
PROGRAMA.jpg (127.73 KiB) Viewed 4640 times
TABLA.jpg
TABLA.jpg (128.26 KiB) Viewed 4640 times
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: BUSQUEDA FILTRADA

Post by esgici »

Here I am with another concern, that achievement does not solve:
In a table of products to sell, there are plenty of items, and are asked to list only certain products with a special feature in the description or name ... this feature does not have a fixed location, you can be at the beginning, middle or end of the name ... they attached images showing the table with the products and then the program screen where it asks to search and it shows, clear that here is complete because even I do not know the solution, however it is marked all you have to show.
Hola Luis

I'm not sure for correct understanding your question :(

Code: Select all

DO WHILE .NOT. EOF()
   IF DATO $ BODEGA
      @ L,10 SAY BODEGA+' '+NOMBRE+STR(STOCK)
      L=L+1
   ENDIF
   SKIP
ENDDO
Viva INTERNATIONAL HMG :D
User avatar
LOUIS
Posts: 256
Joined: Tue Dec 11, 2012 9:05 pm
DBs Used: DBF

Re: BUSQUEDA FILTRADA

Post by LOUIS »

Mr Esgici :

It should only show what is asked ---> GP4
and not all :(

Of course my code is imperfect :oops:
and pray to you for be corrected :roll:

Thanks in advance.
User avatar
luisvasquezcl
Posts: 1259
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: BUSQUEDA FILTRADA

Post by luisvasquezcl »

Creo que también puedes filtrar de la siguiente forma:
SET FILTER TO RAT( upper( cCondicion ), upper( Nombre ) ) != 0
de esta forma te filtrará todos los datos cuyo nombre contengan cCondicion.
Evalúa las posibilidades ya que el filtro puede ser más lento que recorrer la tabla.
Espero te sea de utilidad.
Saludos cordiales,
Luis Vasquez
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: BUSQUEDA FILTRADA

Post by Javier Tovar »

Hola LOUIS,

Eso lo puedes hacer fácil con un While: de esta manera: La Palabra a buscar es cBusca := 'GP4'

Code: Select all

Tabla->(DBGOTOP())
DO WHILE .NOT. EOF()
   IF TABLA->NOMBRE $ cBusca    // Revisa registro por registro si el contenido en el campo TABLA->NOMBRE contiene la palabra 'GP4'
       @ L,10 SAY TABLA->BODEGA+' ' + TABLA->NOMBRE +' '+ STR(TABLA->STOCK)      
       L=L+1
   ENDIF
   SKIP
ENDDO
Saludos
Last edited by Javier Tovar on Fri Feb 27, 2015 9:10 pm, edited 1 time in total.
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: BUSQUEDA FILTRADA

Post by Javier Tovar »

Hola LOUIS,

En clipper puro hay una especie de Grid, Browse o un TBrowse???, desconosco lo que hay en Clipper que puedas ir agregando los registros que va encontrando, solo en vez de ponerlos en pantalla hay que agregarlos en un Control que te menciono.

Saludos
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: BUSQUEDA FILTRADA

Post by esgici »

A correction :

Code: Select all

DO WHILE .NOT. EOF()
   IF DATO $ NOMBRE
      @ L,10 SAY BODEGA+' '+NOMBRE+STR(STOCK)
      L=L+1
   ENDIF
   SKIP
ENDDO
Viva INTERNATIONAL HMG :D
EduardoLuis
Posts: 684
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: BUSQUEDA FILTRADA

Post by EduardoLuis »

Hi Esgici:

+1

Your suggestion is - as allways - the most effective.-
Regards.
Eduardo
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: BUSQUEDA FILTRADA

Post by esgici »

EduardoLuis wrote:Hi Esgici:

+1

Your suggestion is - as allways - the most effective.-
Regards.
Eduardo
Hola Eduardo

I'm glad that your problem solved.

My problem was understand your need.

You can use SET FILTER method as suggested by our dear friend Luis Vasquez :

Code: Select all

SET FILTER TO DATO $ NOMBRE
GO TOP
DO WHILE .NOT. EOF()
   @ L,10 SAY BODEGA+' '+NOMBRE+STR(STOCK)
   L=L+1
   SKIP
ENDDO
Viva Clipper !
Viva INTERNATIONAL HMG :D
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: BUSQUEDA FILTRADA

Post by andyglezl »

Hola LOUIS

Para clipper, yo creo que deberías darle una vista a este link. Ahí encontraras muchas cosas...

--------------------------------------------------------------------------
Hello LOUIS

To clipper, I think you should give a view on this link. There you will find many things ...

http://www.the-oasis.net/ftpmaster.php3 ... pgenrl.htm
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply