Page 2 of 2

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Wed Jan 11, 2023 11:05 am
by tonton2
Bonjour,
comment mettre des fichiers (file1.dbf ,...,files.dbf) qui sont dans un repertoire(c:\directory\*.dbf)) dans listbox et ouvrir une des tables.
merci d'avance
Hello,
how to put files (file1.dbf ,...,files.dbf) which are in a directory (c:\directory\*.dbf) in listbox and open one of the tables.
thank you in advance

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Wed Jan 11, 2023 1:33 pm
by SALINETAS24
tonton2 wrote: Wed Jan 11, 2023 11:05 am Bonjour,
comment mettre des fichiers (file1.dbf ,...,files.dbf) qui sont dans un repertoire(c:\directory\*.dbf)) dans listbox et ouvrir une des tables.
merci d'avance
Hello,
how to put files (file1.dbf ,...,files.dbf) which are in a directory (c:\directory\*.dbf) in listbox and open one of the tables.
thank you in advance
Hola Tonton2, aqui tienes un ejemplo de lo que quieres. Espero que te sirva.

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Wed Jan 11, 2023 5:14 pm
by tonton2
Merci mon ami

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Wed Jan 11, 2023 9:26 pm
by tonton2
Bonjour,
En voulant ouvrir cFile := (BL_Produit.dbf) ,le message suivant apparait, avez une idée pour résoudre ce problème
Bonsoir,
Hello,
When wanting to open cFile:= (BL_Produit.dbf), the following message appears, do you have an idea to solve this problem

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Thu Jan 12, 2023 11:11 am
by tonton2
SALINETAS24 wrote: Wed Jan 11, 2023 1:33 pm
tonton2 wrote: Wed Jan 11, 2023 11:05 am Bonjour,
comment mettre des fichiers (file1.dbf ,...,files.dbf) qui sont dans un repertoire(c:\directory\*.dbf)) dans listbox et ouvrir une des tables.
merci d'avance
Hello,
how to put files (file1.dbf ,...,files.dbf) which are in a directory (c:\directory\*.dbf) in listbox and open one of the tables.
thank you in advance
Hola Tonton2, aqui tienes un ejemplo de lo que quieres. Espero que te sirva.
Bonjour,
Avez vous une idée comment contourner ce probleme
merci.
Do you have any idea how to get around this problem?
thank you
¿Tienes alguna idea de cómo solucionar este problema?
Gracias

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Thu Jan 12, 2023 1:54 pm
by gfilatov
tonton2 wrote: Thu Jan 12, 2023 11:11 am
SALINETAS24 wrote: Wed Jan 11, 2023 1:33 pm
tonton2 wrote: Wed Jan 11, 2023 11:05 am Bonjour,
comment mettre des fichiers (file1.dbf ,...,files.dbf) qui sont dans un repertoire(c:\directory\*.dbf)) dans listbox et ouvrir une des tables.
merci d'avance
Hello,
how to put files (file1.dbf ,...,files.dbf) which are in a directory (c:\directory\*.dbf) in listbox and open one of the tables.
thank you in advance
Hola Tonton2, aqui tienes un ejemplo de lo que quieres. Espero que te sirva.
Bonjour,
Avez vous une idée comment contourner ce probleme
merci.
Do you have any idea how to get around this problem?
thank you
¿Tienes alguna idea de cómo solucionar este problema?
Gracias
Hello,

Please try the updated example below. :arrow:

Code: Select all

/*
* Ejemplo para Listbox + Directory para TONTON2
* Salineta24 - Petrer City (Alicante - SPAIN)
* Email : SARGANTANTASOFT@GMAIL.COM
*/

#include "hmg.ch"

FUNCTION  Main
LOCAL nFor, cCarpeta
LOCAL aNombreFiles:={}   // Solo se usa para la definicion del listbox


	
	DEFINE WINDOW Win1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'CARGAR FICHERO DBF' ;
		MAIN 
		
	    DEFINE MAIN MENU
			DEFINE POPUP "File"
				MENUITEM "Cargar DBF" ACTION  cCarpeta:=CargarDbf()
				SEPARATOR
				MENUITEM "Salir" ACTION ThisWIndow.Release 
			END POPUP
		END MENU
		
		@ 10,10 LISTBOX LIST1 ;
			WIDTH 100 HEIGHT 200 ;
			ITEMS aNombreFiles ;
			ON DBLCLICK EjecutaDBF(cCarpeta)
			

	END WINDOW

	Win1.Center
	ACTIVATE WINDOW Win1 
RETURN

FUNC CargarDBF
LOCAL nFor, cCarperta
LOCAL aTotalFiles:={}
	// Carga Directorio
	cCarpeta:=GetFolder("Directorio DBFґs")
	aTotalFiles:=Directory(cCarpeta+"\*.DBF")
	// Borro todo el Listbox
	DoMethod ( "Win1", "List1", 'DeleteAllItems' )
	FOR nFor=1 To LEN(aTotalFiles)
		DoMethod ( "Win1", "List1", 'AddItem', aTotalFiles[nFor][1] )
	NEXT
RETURN cCarpeta

PROC EjecutaDBF(cCarpeta)
LOCAL cFile
LOCAL nPos
	nPos:=Win1.List1.Value
	IF nPos=0
		MSGBOX("Error en seleccion")
	ELSE
		cFile:=Win1.List1.item(nPos)
		msgbox("FICHERO "+cCarpeta+"\"+cFile)
	
	     	use (cCarpeta+"\"+cFile)  // Ajout
		COPY STRUCTURE TO Gest_ant  FIELDS REFERENCE,PRIX_TOTAL,QUANTITE0
	
             Use Gest_Ant
             APPEND FROM (cCarpeta+"\"+cFile) FIELDS REFERENCE,PRIX_TOTAL,QUANTITE0
		EDIT EXTENDED
	ENDIF 
RETURN

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Thu Jan 12, 2023 3:08 pm
by tonton2
gfilatov wrote: Thu Jan 12, 2023 1:54 pm
tonton2 wrote: Thu Jan 12, 2023 11:11 am
SALINETAS24 wrote: Wed Jan 11, 2023 1:33 pm

Hola Tonton2, aqui tienes un ejemplo de lo que quieres. Espero que te sirva.
Bonjour,
Avez vous une idée comment contourner ce probleme
merci.
Do you have any idea how to get around this problem?
thank you
¿Tienes alguna idea de cómo solucionar este problema?
Gracias
Hello,

Please try the updated example below. :arrow:

Code: Select all

/*
* Ejemplo para Listbox + Directory para TONTON2
* Salineta24 - Petrer City (Alicante - SPAIN)
* Email : SARGANTANTASOFT@GMAIL.COM
*/

#include "hmg.ch"

FUNCTION  Main
LOCAL nFor, cCarpeta
LOCAL aNombreFiles:={}   // Solo se usa para la definicion del listbox


	
	DEFINE WINDOW Win1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'CARGAR FICHERO DBF' ;
		MAIN 
		
	    DEFINE MAIN MENU
			DEFINE POPUP "File"
				MENUITEM "Cargar DBF" ACTION  cCarpeta:=CargarDbf()
				SEPARATOR
				MENUITEM "Salir" ACTION ThisWIndow.Release 
			END POPUP
		END MENU
		
		@ 10,10 LISTBOX LIST1 ;
			WIDTH 100 HEIGHT 200 ;
			ITEMS aNombreFiles ;
			ON DBLCLICK EjecutaDBF(cCarpeta)
			

	END WINDOW

	Win1.Center
	ACTIVATE WINDOW Win1 
RETURN

FUNC CargarDBF
LOCAL nFor, cCarperta
LOCAL aTotalFiles:={}
	// Carga Directorio
	cCarpeta:=GetFolder("Directorio DBFґs")
	aTotalFiles:=Directory(cCarpeta+"\*.DBF")
	// Borro todo el Listbox
	DoMethod ( "Win1", "List1", 'DeleteAllItems' )
	FOR nFor=1 To LEN(aTotalFiles)
		DoMethod ( "Win1", "List1", 'AddItem', aTotalFiles[nFor][1] )
	NEXT
RETURN cCarpeta

PROC EjecutaDBF(cCarpeta)
LOCAL cFile
LOCAL nPos
	nPos:=Win1.List1.Value
	IF nPos=0
		MSGBOX("Error en seleccion")
	ELSE
		cFile:=Win1.List1.item(nPos)
		msgbox("FICHERO "+cCarpeta+"\"+cFile)
	
	     	use (cCarpeta+"\"+cFile)  // Ajout
		COPY STRUCTURE TO Gest_ant  FIELDS REFERENCE,PRIX_TOTAL,QUANTITE0
	
             Use Gest_Ant
             APPEND FROM (cCarpeta+"\"+cFile) FIELDS REFERENCE,PRIX_TOTAL,QUANTITE0
		EDIT EXTENDED
	ENDIF 
RETURN
Thank you very much. I'll test your sample and btw I found a solution. I'll soon send you mine

Re: ARRAY -- ESTOY BLOQUEADO..

Posted: Thu Jan 12, 2023 4:25 pm
by tonton2
RE ,
Voila finalement une partie du programme solutionné
Here is finally a part of the solved program
Aquí está finalmente una parte del programa resuelto.
Merci a tous pour votre Aide