Error menu name variable type accepts only charracter

HMG en Español

Moderator: Rathinagiri

Post Reply
User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Error menu name variable type accepts only charracter

Post by jairpinho » Sun Apr 22, 2012 12:56 am

hello people can not assign a variable to a menu other than character
following example and the image


#include <hmg.ch>

Function Main
LOCAL aMenu := array(10)
Load Window Main

aMenu[1] := "MNU1" -- > does not work
cMenu := "MNU1"


Main.Center
Main.Activate

Return
Attachments
MENU PRINCIPAL.png
MENU PRINCIPAL.png (15.41 KiB) Viewed 1594 times
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
danielmaximiliano
Posts: 2090
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 115 times
Been thanked: 15 times
Contact:

Post by danielmaximiliano » Sun Apr 22, 2012 1:34 am

try this:
a modification of the example menu in hmg.3.0.40
Attachments
Crimson Editor - [Chmg.3.0.40SAMPLESMENU.1demo.jpg
Crimson Editor - [Chmg.3.0.40SAMPLESMENU.1demo.jpg (120.63 KiB) Viewed 1589 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
danielmaximiliano
Posts: 2090
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 115 times
Been thanked: 15 times
Contact:

Post by danielmaximiliano » Sun Apr 22, 2012 2:33 am

other ideas
array.jpg
array.jpg (99.68 KiB) Viewed 1582 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
danielmaximiliano
Posts: 2090
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 115 times
Been thanked: 15 times
Contact:

Post by danielmaximiliano » Sun Apr 22, 2012 4:04 am

Ola Jair:
Try This
macro work.jpg
macro work.jpg (191.04 KiB) Viewed 1576 times
Main.fmg

Code: Select all

* HMG-IDE Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 342 , 504 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "Macro Work" ICON NIL MAIN CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

    DEFINE MAIN MENU
        DEFINE POPUP "Principal" NAME &(aMENU[1])
        END POPUP
    END MENU
    DEFINE MAIN MENU
        DEFINE POPUP "Secundario" NAME &(aMENU[2])
        END POPUP
    END MENU

    DEFINE BUTTON Button_1
        ROW    150
        COL    280
        WIDTH  100
        HEIGHT 28
        ACTION Nil
        CAPTION "Button_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

END WINDOW

*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Sun Apr 22, 2012 4:17 pm

ola daniel funcionou como vc sugeriu porem nao aceita modificar o objeto pelo nome olha o exemplo
o que vou fazer seria um controle de modulo de usuarios onde posso adicionar os modulos para cada usuario sendo assim preciso habilitar ou desabilitar menus e toolbar esse é o proposito.


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)

Load Window Main

aMenu[1] := "MNU1" && -- > does not work
cMenu := "MNU1"

MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA

Main.Center
Main.Activate

Return
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
jairpinho
Posts: 251
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Been thanked: 5 times
Contact:

Post by jairpinho » Sun Apr 22, 2012 4:30 pm

Muito obrigado Daniel Funcionou tive que modificar um pouco a declaração da variavel antes do Load Window


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)
aMenu[1] := "MNU1"

Load Window Main
MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA
Main.Center
Main.Activate

Return
Attachments
MENU PRINCIPAL2.png
MENU PRINCIPAL2.png (10.44 KiB) Viewed 1527 times
Last edited by jairpinho on Sun Apr 22, 2012 7:34 pm, edited 1 time in total.
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
danielmaximiliano
Posts: 2090
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 115 times
Been thanked: 15 times
Contact:

Post by danielmaximiliano » Sun Apr 22, 2012 7:18 pm

jairpinho wrote:ola daniel funcionou como vc sugeriu porem nao aceita modificar o objeto pelo nome olha o exemplo
o que vou fazer seria um controle de modulo de usuarios onde posso adicionar os modulos para cada usuario sendo assim preciso habilitar ou desabilitar menus e toolbar esse é o proposito.


#include <hmg.ch>

Function Main
declare window main
LOCAL aMenu := array(10)

Load Window Main

aMenu[1] := "MNU1" && -- > does not work
cMenu := "MNU1"

MODIFY CONTROL MNU1 OF Main ENABLED .F. // NÃO FUNCIONA

Main.Center
Main.Activate

Return
según la referencia de HMG para el Control Main Menu.
não pode mudar os valores no menu principal

Code: Select all

DEFINE MAINMENU [ PARENT <ParentWindowName> ]
   DEFINE POPUP <cPopupCaption> [ NAME <PopupName> ]
     MENUITEM <cItemCaption>
         ONCLICK <ActionProvedureName> | <bBlock>
             [ NAME <MenuItemName>]
                 [ IMAGE <cImageName> ]
                    [ CHECKED <lValue> ]
                   ..
                   ..
                [ SEPARATOR ]
                  ...
                  ...
    END POPUP
                  ...
                  ... 
 END MENU

MainMenu Properties:

 - Parent (R)
   R: Read-Only

MenuItem Properties:

  - Name (R)
  - Checked
  - Enabled
  - Image
  R: Read-Only

MenuItem Events:

 - OnClick (R)
  R: Read-Onl
HMG.4 possivelmente pode fazê-lo.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
danielmaximiliano
Posts: 2090
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 115 times
Been thanked: 15 times
Contact:

Post by danielmaximiliano » Sun Apr 22, 2012 8:24 pm

Hola Jair:
aqui tiene un ejemplo de utilizar una Macro "&" para crear menu personalizado.
Main.prg

Code: Select all

#include <hmg.ch>

Function Main
Public aMenu := {'JairMenu'  , 'RobertoMenu'  , 'DanielmaximilianoMenu', 'OtherMenu'  }
Public aPopup:= {'Popup' , 'Popup' , 'Popup' }
Public aItems:= {'Items1' , 'Items1' , 'Items1' }
Public aUsers:= {'Jair'   , 'Roberto', 'DanielMaximiliano' , 'Other'  }
Public cUsers := getenv("UserName")
Public cPopup := 'Principal'
Public xMenu  := 0
        Load Window Main
        Main.Center
        Main.Activate
Return

Function Mainname(cUser)
Local cMainname :=  ''
 Do case
    Case cUsers = 'Jair'
    cMainname := aMenu[1]
    xMenu     := 1
    Case cUsers = 'Roberto'
    cMainname := aMenu[2]
    xMenu     := 2
    Case cUsers = 'Other'
    cMainname := aMenu[3]
    xMenu     := 3
    Case cUsers = 'DanielMaximiliano'
    cMainname := aMenu[3]
    xMenu     := 4
 Endcase
 cPopup := cPopup + cMainname
Return (cMainname)
Main.fmg
* HMG-IDE Form Designer Generated Code
* (c) Roberto Lopez - http://sites.google.com/site/hmgweb

DEFINE WINDOW TEMPLATE AT 183 , 360 WIDTH 550 HEIGHT 350 VIRTUAL WIDTH Nil VIRTUAL HEIGHT Nil TITLE "Macro Work" ICON NIL MAIN CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON MOUSECLICK Nil ON MOUSEDRAG Nil ON MOUSEMOVE Nil ON SIZE Nil ON MAXIMIZE Nil ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil NOTIFYICON NIL NOTIFYTOOLTIP NIL ON NOTIFYCLICK Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil ON SCROLLUP Nil ON SCROLLDOWN Nil ON SCROLLLEFT Nil ON SCROLLRIGHT Nil ON HSCROLLBOX Nil ON VSCROLLBOX Nil

DEFINE MAIN MENU
DEFINE POPUP &("Mainname()") NAME &(aMenu[xMenu])
END POPUP
END MENU

DEFINE STATUSBAR FONT "Arial" SIZE 9
STATUSITEM "User : "+cUsers WIDTH 300 ACTION Nil ICON "Users" TOOLTIP "Usuario Logueado"
END STATUSBAR

DEFINE BUTTON Button_1
ROW 90
COL 200
WIDTH 100
HEIGHT 28
ACTION Nil
CAPTION "Button_1"
FONTNAME "Arial"
FONTSIZE 9
TOOLTIP ""
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
ONGOTFOCUS Nil
ONLOSTFOCUS Nil
HELPID Nil
FLAT .F.
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
MULTILINE .F.
PICTURE Nil
PICTALIGNMENT TOP
END BUTTON

END WINDOW
Macro Work_2012-04-22_17-25-03.jpg
Macro Work_2012-04-22_17-25-03.jpg (16.21 KiB) Viewed 1523 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

Post Reply