|
From: Alain A. <ala...@wa...> - 2015-03-29 14:26:29
|
Hi,
I'm building a genealogy helper application to access to the omline
registry of french departements.
For now, I'm just using one departement. It has 576 cities.
To build a menu, is a real pain.
So, I try to create it using a dbf file (with a short menu first.
If I code it like this, menu is correctly created, but it fail to
execute the ACTION (does nothing):
MENU TITLE "Télécharger une &décénale"
for rg=1 to 4
MENU TITLE tabdec[rg,1]
MENUITEM tabdec[rg,2] ACTION tabdec[rg,3]
ENDMENU
next
ENDMENU
I have tried to use ACTION eval(tabdec[rg,3], but it generate an error.
Is there a way to do it ?
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 (2015-03-27 15:21) |
HbIDE (Rev.316) | Five.Linux (r138) | Hw.Gui (2375)
------------------------------------------------------------------------
|
|
From: Alain A. <ala...@wa...> - 2015-03-29 15:00:30
|
Le 29. 03. 15 16:26, Alain Aupeix a écrit :
> Hi,
>
> I'm building a genealogy helper application to access to the omline
> registry of french departements.
>
> For now, I'm just using one departement. It has 576 cities.
> To build a menu, is a real pain.
> So, I try to create it using a dbf file (with a short menu first.
I have now found a solution:
/local tabdec:={}, rg, action, param//
//....//
//select 3//
//use dec//
//go top//
//for rg=1 to lastrec()//
//
aadd(tabdec,{trim(dec->title),trim(dec->item),trim(dec->command),trim(dec->param)})//
// skip//
//next//
//.....//
//MENU TITLE "Télécharger une &décénale"//
//for rg=1 to 4//
// MENU TITLE tabdec[rg,1]//
// action=tabdec[rg,3]//
// param=tabdec[rg,4]//
// MENUITEM tabdec[rg,2] ACTION &(action)('"'+param+'"')//
// ENDMENU//
//next//
ENDMENU
/
I just need to improve to allow more than one parameter, and embedded menus
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 (2015-03-27 15:21) |
HbIDE (Rev.316) | Five.Linux (r138) | Hw.Gui (2375)
------------------------------------------------------------------------
|
|
From: Alain A. <ala...@wa...> - 2015-03-30 17:12:02
|
Le 29. 03. 15 17:00, Alain Aupeix a écrit :
> I just need to improve to allow more than one parameter, and embedded
> menus
I have modified my first test, to generate menus and submenus.
When developping the menu structure, it works except when there the menu
command is MENUITEM (at the end of the creation)
Action doesn't work as expected.
The parameters are always the one of the last record.
I had first the problem using directly the fields in the process.
I replaced by an array and it's the same problem.
Here is the code:
local aDepart:={}, aMenus:={}, cDept, nbdep, nbcom, nbmenu, rgd, rgc,
action, param1, param2, cCanton, cArrondissement, nDept, nTab:=0
// Prérequis des Menus
select 2
use communes index decaco
nbcom=lastrec()
go top
select 3
use departments index depart
go top
nbdep=lastrec()
go top
for rgd=1 to nbdep
select 3
aadd(aDepart,{departments->deparmnt,departments->code})
select 2
rgd=1
do while trim(communes->deparmnt) == trim(departments->deparmnt)
aadd(aCommune,{communes->insee,communes->postal,communes->commune,communes->canton,communes->arondmnt,communes->deparmnt,communes->immatric,communes->latitude,communes->longitude,communes->indice,rgd})
rgd++
skip
enddo
next
select 3
nbdep=lastrec()
// Menus
MENU OF oMainWindow
MENU TITLE "&Fichier"
MENUITEM "&Ouvrir" ACTION FileOpen()
SEPARATOR
MENUITEM "Configuration" ACTION IniEdit()
SEPARATOR
MENUITEM "&Quitter" ACTION Quitter()
ENDMENU
MENU TITLE "&Outils"
MENUITEM "&Lire un registre (local)" ACTION ReadReg()
MENU TITLE "Archives départementales"
for rgd = 1 to nbdep
cDept = aDepart[rgd,1]
nDept = aDepart[rgd,2]
MENU TITLE trim(cDept)
MENU TITLE "Accéder aux communes"
rgc=1
do while trim(aCommune[rgc,6]) == trim(cDept)
cArrondissement = aCommune[rgc,5]
cCanton = aCommune[rgc,4]
MENU TITLE trim(cArrondissement)
do while aCommune[rgc,5] == cArrondissement
cCanton = aCommune[rgc,4]
MENU TITLE trim(cCanton)
do while aCommune[rgc,4] == cCanton
action="canton24"
param1=trim(aCommune[rgc,4])
param2=trim(aCommune[rgc,10])
cCommune = trim(aCommune[rgc,3])
// this qout confirms that the values are correct during the construct
process
qout(cCommune+space(40-len(cCommune))+action+"("+param1+","+param2+")")
MENUITEM cCommune ACTION
&(action)('"'+param1+'"','"'+param2+'"')
rgc++
if rgc > nbcom
exit
endif
enddo
ENDMENU
rgc++
if rgc > nbcom
exit
endif
enddo
ENDMENU
rgc++
if rgc > nbcom
exit
endif
enddo
ENDMENU
SEPARATOR
MENUITEM "&Télécharger un BMS" ACTION Commune("bms")
MENUITEM "Télécharger une &décénale" ACTION Commune("dec")
ENDMENU
next
ENDMENU
...
ENDMENU
I really don't understand what is the problem.
If you have an idea ...
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 (2015-03-27 15:21) |
HbIDE (Rev.316) | Five.Linux (r138) | Hw.Gui (2375)
------------------------------------------------------------------------
|
|
From: Alexander S.K. <al...@be...> - 2015-04-07 11:39:05
|
Try the following:
Hwg_DefineMenuItem( cCommune,, &( "{||" + action + "(" + param1 + "," +
param2 + ")}" ) )
instead of
> MENUITEM cCommune ACTION &(action)('"'+param1+'"','"'+param2+'"')
Regards, Alexander.
|
|
From: Alain A. <ala...@wa...> - 2015-04-07 12:41:39
|
Le 07. 04. 15 12:38, Alexander S.Kresin a écrit :
> Try the following:
>
> Hwg_DefineMenuItem( cCommune,, &( "{||" + action + "(" + param1 + "," +
> param2 + ")}" ) )
An error occured, but I suppose it was due to the content of param1
Here is the line which works:
Hwg_DefineMenuItem( cCommune,, &( "{||" + action + "("+'"' + param1 +
'","' + param2 + '")'+"}" ) )
the string separator is melting ' and ", it's not especially viewable
here, except in : '")'
> instead of
>
>> MENUITEM cCommune ACTION &(action)('"'+param1+'"','"'+param2+'"')
Thanks a lot. It allows to reduce the number of line just for this menu
and submenus from 678 line to 34 lines.
:)
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 (2015-03-27 15:21) |
HbIDE (Rev.316) | Five.Linux (r138) | Hw.Gui (2375)
------------------------------------------------------------------------
|