|
From: Alain A. <ala...@wa...> - 2014-10-22 17:48:20
|
Hi,
I have tried to use ON CHANGE
I have put all the tab init in each a function and tried
I have put some Qout to see what happens
The
Here is the source of the concerned part of my tool:
//
============================================================================
Function ReadReg()
//
============================================================================
Local aCom:={}, maxi:=.f., cMessage
Local oDlg, oFont := HFont():Add( "Serif",0,-13 )
Local cTitle := "Ouverture d'un registre"
Local cText01 := "Choisissez la commune"
Local cText02 := "Choisissez le type de registre"
Local cText03 := "Choisissez le registre"
Local cCommune:="", cType:="", cRegistre:="", lBox:=.t.
// init of tabs
SearchCommune()
Qout("Communes " +str(len(aCommunes)))
SearchType(aCommunes[1])
Qout("Types " +str(len(aTypes)))
SearchRegistre(aCommunes[1],aTypes[1])
Qout("Registres "
+str(len(aRegistres))+chr(10)+"------------------------------------------"+chr(10))
// Here is what is output:
// aCommunes[1] Chalais
// Communes 30
// Chalais :
// aTypes[1] Décès
// Types 3
// Chalais/Décès :
// aRegistres[1] CHALEIX_DECES_1803-1812.PDF
// Registres 10
// ------------------------------------------
// All is right
if len(aCommunes)>0 .and. len(aTypes)>0 .and. len(aRegistres)>0
lBox=.f.
INIT DIALOG oDlg CLIPPER NOEXIT TITLE cTitle AT ox+140,oy+130 SIZE
520,180 ;
FONT oFont
@ 15,10 SAY cText01 SIZE 200, 22 COLOR hwg_VColor("FF0000")
@ 15,32 GET COMBOBOX cCommune ITEMS aCommunes STYLE WS_TABSTOP SIZE
290, 25;
TOOLTIP "Choix de la commune";
ON CHANGE {||SearchType(cCommune)};
TEXT
// With on change I expected to update the tab and the next combobox
//
// Chalais :
// aTypes[1] Décès
//
// but i nok
// if I do it again:
//
// Jumilhac-le-Grand :
// aTypes[1] BMS
//
// What is wrong:
//
// - The value of the tab is changed on next 'ON CHANGE' call
// - The content of the combobox is never updated.
//
// This for all the concerned combobox
//
// Have you an idea of the reason of seach problems ?
// I have tried ON INIT, but it fails (syntax error)
// How to refresh tabs and combobox ?
@ 325,10 SAY cText02 SIZE 200, 22 COLOR hwg_VColor("FF0000")
@ 325,32 GET COMBOBOX cType ITEMS aTypes STYLE WS_TABSTOP SIZE 110, 25;
TOOLTIP "Choix du type de registre";
ON CHANGE {||SearchRegistre(cCommune, cType)};
TEXT
@ 15,62 SAY cText03 SIZE 200, 22 COLOR hwg_VColor("FF0000")
@ 15,84 GET COMBOBOX cRegistre ITEMS aRegistres STYLE WS_TABSTOP
SIZE 490, 25;
TOOLTIP "Choix du registre";
TEXT
@ 120,130 BUTTON "Ok" OF oDlg ID IDOK ;
SIZE 100, 32 COLOR hwg_VColor("FF0000") ;
ON CLICK {||oDlg:lResult:=.t.}
@ 260,130 BUTTON "Annuler" OF oDlg ID IDCANCEL ;
SIZE 100, 32
ACTIVATE DIALOG oDlg
oFont:Release()
if oDlg:lresult
run(cview+' "'+crpath+"/"+cCommune+"/"+cType+"/"+cRegistre+'" &')
endif
else
Do case
case len(aCommunes)=0
cMessage="Aucune commune trouvé ..."
case len(aTypes)=0
cMessage="Aucun type trouvé ..."
case len(aRegistres)=0
cMessage="Aucun registre trouvé ..."
endCase
hwg_Msginfo(cMessage,"Lire un registre")
endif
Return Nil
//
============================================================================
Function SearchCommune()
//
============================================================================
Local rg, aCom:={}, adir:={}
adel(aCommunes)
aCommunes:={}
aCom=directory(crPath+"/*","D")
adir=asort(aCom,,,{| x, y | x[ 1 ] < y[ 1 ] })
for rg=1 to len(aCom)
if aCom[rg,5] == "D"
aadd(aCommunes,aCom[rg,1])
endif
next
qout("aCommunes[1] "+aCommunes[1])
Return Nil
//
============================================================================
Function SearchType(cCommune)
//
============================================================================
Local rg, aCom:={}, adir:={}
qout(cCommune+" :")
adel(aTypes)
aTypes:={}
aCom=directory(crPath+"/"+cCommune+"/*","D")
adir=asort(aCom,,,{| x, y | x[ 1 ] < y[ 1 ] })
for rg=1 to len(aCom)
if aCom[rg,5] == "D"
aadd(aTypes,aCom[rg,1])
endif
next
qout("aTypes[1] "+aTypes[1])
Return Nil
//
============================================================================
Function SearchRegistre(cCommune,cType)
//
============================================================================
Local rg, aCom:={}, adir:={}
qout(cCommune+"/"+cType+" :")
adel(aRegistres)
aRegistres:={}
aCom=directory(crPath+"/"+cCommune+"/"+cType+"/*.pdf","")
if len(acom)=0
adel(aCom)
aCom:={}
aCom=directory(crPath+"/"+cCommune+"/"+cType+"/*.PDF","")
Endif
adir=asort(aCom,,,{| x, y | x[ 1 ] < y[ 1 ] })
for rg=1 to len(aCom)
aadd(aRegistres,aCom[rg,1])
next
qout("aRegistres[1] "+aRegistres[1])
Return Nil
//
============================================================================
Thanks
A+
--
------------------------------------------------------------------------
Alain Aupeix
http://jujuland.pagesperso-orange.fr/
http://pissobi-lacassagne.pagesperso-orange.fr/
------------------------------------------------------------------------
U.buntu 12.04 | G.ramps 3.4.8-1 | H.arbour 3.2.0dev (2014-10-22 08:25) |
HbIDE (Rev.316) | Five.Linux (r138) | Hw.Gui (2295)
------------------------------------------------------------------------
|