FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MENUITEM with BLOCK command executed TWICE. (SOLVED)
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
MENUITEM with BLOCK command executed TWICE. (SOLVED)
Posted: Mon May 10, 2021 09:25 PM
Hi,

I use MENU... ENDMENU like below. I use BLOCK command in MENUITEM.

Code (fw): Select all Collapse
    MENU oFaizMenu POPUP 2007
        MENUITEM "Parameters" ACTION Parametre_FAIZ()
        SEPARATOR
    FOR hh:=1 TO 19
        hhh:="oApp:xADI_"+ALLTRIM(STR(hh))
        hhh1 := ALLTRIM(&hhh)
        IF !EMPTY(Hhh1)
            MENUITEM hhh1 BLOCK GenBlock_Faiz(hh)
        ENDIF
    Next hh
    ENDMENU

Code (fw): Select all Collapse
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }


When I select blocked option, it is executed twice. I use fwh 2102 revised. Am I doing something wrong?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 07:35 AM
Code (fw): Select all Collapse
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN  &( "{|| " + cProc + "() }" )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 07:42 AM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN  &( "{|| " + cProc + "() }" )


Thank you Mr. Rao,

I have tried but There is still same error.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 08:52 AM

ty to insert the action before of the BLOCK

baction := GenBlock_Faiz(hh)
MENUITEM hhh1 BLOCK bAction

FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }

on a my menu I make this

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 08:55 AM
Silvio.Falconi wrote:ty to insert the action before of the BLOCK


baction := GenBlock_Faiz(hh)
MENUITEM hhh1 BLOCK bAction

FUNCTION GenBlock_Faiz(nhh)
LOCAL cProc := "Faiz"+ALLTRIM(STR(nhh))
RETURN {|| &(cProc)() }

on a my menu I make this


Thank you Silvio, Tried and same error.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:25 AM
This example works fine:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU   
   ENDMENU

return oMenu
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:30 AM
This one also works fine:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK GenBlock()
         ENDMENU   
   ENDMENU

return oMenu

function GenBlock()

return { || MsgInfo( "Hello" ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:33 AM
Trying to get an example similar to yours, and this is working fine also:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu, n 

   MENU oMenu
      MENUITEM "First"
      MENU
         for n = 1 to 5
            MENUITEM "test" BLOCK GenBlock( n )
         next   
      ENDMENU   
   ENDMENU

return oMenu

function GenBlock( n )

return { || MsgInfo( n ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:33 AM
yes confirm this run ok

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()

   local oMenu,n,baction 

   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next 
         ENDMENU  
   ENDMENU

return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }


  Function Hello4()
     return  Msginfo("run")


it run one time probable popmenu run bad
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:38 AM
Antonio Linares wrote:This example works fine:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU   
   ENDMENU

return oMenu


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code (fw): Select all Collapse
   MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:45 AM
Horizon wrote:
Antonio Linares wrote:This example works fine:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU   
   ENDMENU

return oMenu


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code (fw): Select all Collapse
   MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU




Horizon,
the popup menu run ok

Please try this test with ribbonbar

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "ribbon.ch"

function Main()

   local oWnd,oRBar,oTBtn0
   local aClrMenu1 := { { 0.5, RGB( 69, 124, 188 ), RGB( 41, 93, 171 ) }, ;
                        { 0.5, RGB( 26, 64, 136 ), RGB( 56, 135, 191 ) } }

   DEFINE WINDOW oWnd MENU BuildMenu()
   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25


  oTBtn0 = TRBtn():New( 4, 0, 70, 20, "..\bitmaps\rbnmenu.bmp", { || oRBar:BackStage() /* oRBar:KeybMode() */ }, oRBar,;
                         ,,,,,, .T., .T.,,,,,, "POPUP", BuilPopMenu(),,,,,,,,,,,,, aClrMenu1, nRGB( 125, 172, 215 ),;
                         nRGB( 65, 106, 189 ) )




   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()
   local oMenu,n,baction
   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next 
         ENDMENU
   ENDMENU
return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }

  Function Hello4()
    return  Msginfo("run")


Function  BuilPopMenu()
   local oMenu,n,baction
     MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next 
         ENDMENU  
   ENDMENU
   return oMen
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:51 AM
Silvio.Falconi wrote:
Horizon wrote:
Antonio Linares wrote:This example works fine:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oWnd

   DEFINE WINDOW oWnd MENU BuildMenu()

   ACTIVATE WINDOW oWnd

return nil

function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "First"
         MENU
            MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
         ENDMENU   
   ENDMENU

return oMenu


You are right Antonio,

Please find ribbon.prg from samples directory and change this lines and compile.

Code (fw): Select all Collapse
   MENU oMenu POPUP 2007
      MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
      MENUITEM "Colors"
      MENUITEM "Font"
      MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
   ENDMENU




Horizon,
the popup menu run ok

Please try this test with ribbonbar

Code (fw): Select all Collapse
#include "fivewin.ch"
#include "ribbon.ch"

function Main()

   local oWnd,oRBar,oTBtn0
   local aClrMenu1 := { { 0.5, RGB( 69, 124, 188 ), RGB( 41, 93, 171 ) }, ;
                        { 0.5, RGB( 26, 64, 136 ), RGB( 56, 135, 191 ) } }

   DEFINE WINDOW oWnd MENU BuildMenu()
   DEFINE RIBBONBAR oRBar WINDOW oWnd PROMPT "Configuración", "Ficheros", "Informes", "Ayudas" HEIGHT 133 TOPMARGIN 25


  oTBtn0 = TRBtn():New( 4, 0, 70, 20, "..\bitmaps\rbnmenu.bmp", { || oRBar:BackStage() /* oRBar:KeybMode() */ }, oRBar,;
                         ,,,,,, .T., .T.,,,,,, "POPUP", BuilPopMenu(),,,,,,,,,,,,, aClrMenu1, nRGB( 125, 172, 215 ),;
                         nRGB( 65, 106, 189 ) )




   ACTIVATE WINDOW oWnd

return nil



function BuildMenu()
   local oMenu,n,baction
   MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next 
         ENDMENU
   ENDMENU
return oMenu

Function givemefunc(n)
   return { || &( "Hello"+ltrim(str(n)) )() }

  Function Hello4()
    return  Msginfo("run")


Function  BuilPopMenu()
   local oMenu,n,baction
     MENU oMenu
      MENUITEM "First"
         MENU
            For n= 4 to 4
             baction:= givemefunc(n)
            MENUITEM "test"+ltrim(str(n)) BLOCK baction
           next 
         ENDMENU  
   ENDMENU
   return oMen


Hi Silvio,

What is your fwh version? After 20.12, there is something strange behavior Menu. I have fwh 21.02.

Please find ribbon.prg from samples directory and change this lines and compile.

Code:
MENU oMenu POPUP 2007
MENUITEM "Style Set" FILE "..\bitmaps\styleset161.BMP"
MENUITEM "Colors"
MENUITEM "Font"
MENUITEM "test" BLOCK { || MsgInfo( "Hello" ) }
ENDMENU
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 09:54 AM

confirm not run
here run twice

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 03:17 PM

Please test your compiled example and tell me if it works for you.

https://bitbucket.org/fivetech/fivewin- ... rizon2.exe

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: MENUITEM with BLOCK command executed TWICE.
Posted: Tue May 11, 2021 03:34 PM
cnavarro wrote:Please test your compiled example and tell me if it works for you.
https://bitbucket.org/fivetech/fivewin- ... rizon2.exe


Hi Mr. Navarro,

I could not downloaded the file.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06