|
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)
------------------------------------------------------------------------
|
|
From: Alain A. <ala...@wa...> - 2014-10-23 07:52:00
|
Le 22/10/2014 19:48, Alain Aupeix a écrit : > 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 I tried this morning to use the debugger, building with -b On the first try, I put a breakpoint on the tab lenght test. and run with F8 => it blocks my X server, and I reboot A second test with using F9 and F8 works Here are the values on console: Activate Dialog : 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 ------------------------------------------ ok, thats good Changing the city (cCommune) Chalais : aTypes[1] Décès Thats wrong. The value appears after a second change, too late: Jumilhac-le-Grand : aTypes[1] BMS And As I said, if the values are changed, but too lately, the combobox aren't updated. 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) ------------------------------------------------------------------------ |
|
From: Alexander S.K. <al...@be...> - 2014-10-23 12:20:08
|
Alain Aupeix writes:
> 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
> ...
It's difficult to reproduce your sample, because, as I understood,
it needed to have a certain structure of directories. It would be good,
if you provide more simple code - it does not matter, how the array are
filled, this part may be simplified.
I didn't understand, what you mean when you talk about 'tab' - I
didn't find any TAB control in the code.
Anyway, I suppose that the problem appears, because you don't
refresh the combobox ( oCombo:Refresh() ) after rebuilding the array in
SearchType() function.
Regards, Alexander.
|
|
From: Alain A. <ala...@wa...> - 2014-10-23 14:29:48
|
Le 23/10/2014 14:19, Alexander S.Kresin a écrit :
> Alain Aupeix writes:
>> 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
>> ...
> It's difficult to reproduce your sample, because, as I understood,
> it needed to have a certain structure of directories. It would be good,
> if you provide more simple code - it does not matter, how the array are
> filled, this part may be simplified.
I don't think it could be simplified.
> I didn't understand, what you mean when you talk about 'tab' - I
> didn't find any TAB control in the code.
Just a typo, I ought to talk about array
> Anyway, I suppose that the problem appears, because you don't
> refresh the combobox ( oCombo:Refresh() ) after rebuilding the array in
> SearchType() function.
Yes, it's probably the reason. But I have an error
@ 15,32 GET COMBOBOX cCommune ITEMS aCommunes STYLE WS_TABSTOP SIZE
290, 25;
TOOLTIP "Choix de la commune" ON CHANGE
{||SearchType(cCommune),cType:Refresh()};
TEXT
Error BASE/1004 No exported method: REFRESH
Called from REFRESH(0)
Called from (b)READREG(690)
Called from HCOMBOBOX:ONEVENT(112)
A+
But the array, and combo which is updated isn't the one which execute
>
> Regards, Alexander.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Hwgui-developers mailing list
> Hwg...@li...
> https://lists.sourceforge.net/lists/listinfo/hwgui-developers
>
--
------------------------------------------------------------------------
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)
------------------------------------------------------------------------
|
|
From: Alexander S.K. <al...@be...> - 2014-10-24 05:30:28
|
> Yes, it's probably the reason. But I have an error
>
> @ 15,32 GET COMBOBOX cCommune ITEMS aCommunes STYLE WS_TABSTOP SIZE
> 290, 25;
> TOOLTIP "Choix de la commune" ON CHANGE
> {||SearchType(cCommune),cType:Refresh()};
> TEXT
>
> Error BASE/1004 No exported method: REFRESH
Naturally. What cType is ? You need the combobox object, to have it
you can define the get combobox with such syntax:
@ 15,32 GET COMBOBOX oCombo VAR cCommune ITEMS aCommunes ...
Then you can write oCombo:Refresh()
Regards, Alexander.
|
|
From: Alain A. <ala...@wa...> - 2014-10-29 10:53:19
Attachments:
genetools.prg
Error.log
|
Le 28/10/2014 11:21, Alexander S.Kresin a écrit : >> >> I no more use adel(), but I use asize(), because I suspect that the new >> array isn't the same as the previous. >> >> But I'm always expecting no more crash, without success >> > > What kind of a crash ? What is the crash message ? Where and when it > happens ? > > Regards, Alexander. > With the version I send you of my prg, when changing the city, it crashes my X11 session, nothing to do else change the system console (ctrl-Alf-F1, for exemple) connect in console mode and stop the computer (sudo halt -p) If I set the variables values in Searchxxx(), the next combobox is updated one time late, and in fine, I can't generate a good path, and open the file I want. I join a version of the prg, an the Error log If you want to try, you can use the version I send in zip, and just update the three concerned functions. 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) ------------------------------------------------------------------------ |
|
From: Alexander S.K. <al...@be...> - 2014-10-29 13:51:34
|
Should be fixed now, the problem was that appropriate get variable (
cType in your case ) wasn't initialized, because that combobox doesn'r
set a focus yet.
Btw, there is no need to write
adel(aCom)
aCom:={}
aCom=directory(crPath+"/"+cCommune+"/"+cType+"/*.PDF","")
One assignment is enough.
Regards, Alexander.
|
|
From: Alain A. <ala...@wa...> - 2014-10-29 21:45:13
|
Le 29/10/2014 13:51, Alexander S.Kresin a écrit :
> Should be fixed now, the problem was that appropriate get variable (
> cType in your case ) wasn't initialized, because that combobox doesn'r
> set a focus yet.
There is no more crash, but the value of the variable isn't yet set to
the new value when on change is executed.
So it's not good.
Is there a way, using a function related to the combo, to have the good
value. oCombo:xxx()
> Btw, there is no need to write
>
> adel(aCom)
> aCom:={}
> aCom=directory(crPath+"/"+cCommune+"/"+cType+"/*.PDF","")
>
> One assignment is enough.
ok, 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)
------------------------------------------------------------------------
|
|
From: Alexander S.K. <al...@be...> - 2014-10-30 07:16:40
|
> There is no more crash, but the value of the variable isn't yet set to > the new value when on change is executed. Probably, now this is fixed, too. > > Is there a way, using a function related to the combo, to have the good > value. oCombo:xxx() What is a good value ? There is a method oCombo:GetValue(), which returns the current value of a combobox and set the oCombo:value and the value of appropriate get variable, if this is a GET COMBOBOX. Now, after the last commit, this method is called automatically when "changed" signal comes, so in ON CHANGE codeblock we can now use :value or the get variable - they have fresh values. Regards, Alexander. |