confusing with enumerations

Just starting out? Need help? Post your questions and find answers here.
ludoke
Enthusiast
Enthusiast
Posts: 153
Joined: Fri Jul 08, 2016 5:35 pm
Location: Essen (Belgium)

confusing with enumerations

Post by ludoke »

;confusion about enuration
I thought to group the enumeration into related containers, but that does not seem to work.
There is only one container visible,remove the inside enumerate and end enumerate then it works.
I am still a beginner !
;

Code: Select all

EnableExplicit
Enumeration
  #main_window
#font22:#font31
#F2:#F4
EndEnumeration
Enumeration ;home container
   #home: #homeX: #homeY: #homeZ: #homeAll  ;container +buttons
   #T_home:#T_home_X:#T_home_y:#T_home_z:#T_home_all ;texten
 EndEnumeration  ;when this delete <---------------

 Enumeration  ;zero container   and also delete this <------------------------it will works
    #zero : #zeroX: #zeroY: #zeroZ:  #zeroA  ;container +invoer
    #T_zero:#T_zeroX:#T_zeroY:#T_zeroZ:#T_zeroA ;texten
 EndEnumeration
;
  Global win_color.l=$EFCEA9; $0   ;achtergrondkleur window
  Global ev
  Global wFlags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget |   #PB_Window_MinimizeGadget
;-----------------------------------------------------------------------------------
Declare home()
Declare zero()
Declare open_win()
;-----------------------------------                                                             
          open_win()         ;open the mainwindow        
;-------------------------------------------------------------------------
  
 Repeat
    Ev = WaitWindowEvent()
    Select ev   ;
        Case #PB_Event_Menu                  
            Select  EventMenu()               
                Case #F2     ;main
                   home()       
               EndSelect
     
        Case #PB_Event_Gadget    
            Select EventGadget()
              Case #HOME     ;main 
                Debug "test F2"
                 home()  
               Case  #homey 
                  Debug "homey"
               Case #F4
                 Debug "test"
              EndSelect  
    EndSelect
    Until ev=#PB_Event_CloseWindow


 End   
 ;------------------------------------------------------------------------------------------------------------------------ 
Procedure open_win()  ;open main window
  
  If OpenWindow (#main_window,0,0,1000,1000, "" ,wflags )
    SetWindowColor(#main_window,win_color)
    home()
    zero()
  EndIf    
EndProcedure  
;------------------------------------------------------------------------------------ 
   Procedure home()
    Define xhome.i=20 , yhome.i=1000-250;positie home container
    Define breedte_home=150 ,hoogte_home =245 ;breedte en hoogte container
    Define home_knop_x=35 ,home_knop_y=40
    Define home_knop_breedte=100,home_knop_hoogte=30
    Define home_tussen=50
     LoadFont(#font22,"arial",12, #PB_Font_Bold) 
     SetGadgetFont(#PB_Default, FontID(#font22))
    ; ContainerGadget(#home,xhome,yhome,breedte_home,hoogte_home,#PB_Container_Raised )
     ContainerGadget(#home,20,750,150,245,#PB_Container_Raised )   : SetGadgetColor(#home, #PB_Gadget_BackColor,  $B19474)
    TextGadget(#T_home,15,10,120,15,"HOME ctrl+axis"):SetGadgetColor(#T_home, #PB_Gadget_BackColor,$B19474  ) 
    
    ButtonGadget(#homeX,home_knop_x,home_knop_y, home_knop_breedte,home_knop_hoogte,"F2 HOME X")
    ButtonGadget(#homey,home_knop_x,home_knop_y+home_tussen, home_knop_breedte,home_knop_hoogte,"F3 HOME Y")
    ButtonGadget(#homez,home_knop_x,home_knop_y+2*home_tussen, home_knop_breedte,home_knop_hoogte,  "F4 HOME Z")
    ButtonGadget(#homeall,home_knop_x,home_knop_y+3*home_tussen, home_knop_breedte,home_knop_hoogte," F5    ALL", #PB_Button_Left )
  ; indicating mark red=Not homed ($0000FD) green is homed ($0CFD00)
  TextGadget(#T_home_X,10,home_knop_y,20,home_knop_hoogte,"")  :  SetGadgetColor(#T_home_x, #PB_Gadget_BackColor,$0000FD  ) 
   TextGadget(#T_home_Y,10,home_knop_y +home_tussen,20,home_knop_hoogte,"") : SetGadgetColor(#T_home_Y, #PB_Gadget_BackColor,$0000FD )
   TextGadget(#T_home_z,10,home_knop_y+2*home_tussen,20,home_knop_hoogte,"") : SetGadgetColor(#T_home_Z, #PB_Gadget_BackColor,$0000FD )
   TextGadget(#T_home_all,10,home_knop_y+3*home_tussen,20,home_knop_hoogte,""):SetGadgetColor(#T_home_all, #PB_Gadget_BackColor,$0000FD)    
     CloseGadgetList()
  EndProcedure
  ;-----------------------------------------------------------------------------------------
  Procedure zero() ;ZEROING 
    
       Define xzero.i=190 ,yzero.i=1000-250;positie zero container
       Define breedte_zero=220,hoogte_zero=245
       Define zero_tussen=50       
       Define zero_text_x=50 ,zero_text_y=40
       Define zero_text_breedte=100,zero_text_hoogte=30         
       ContainerGadget(#zero,xzero,yzero,breedte_zero,hoogte_zero,#PB_Container_Raised )
        SetGadgetColor(#zero, #PB_Gadget_BackColor,  $B19474  )
        TextGadget(#T_zero,20,10,190,15,"SET alt+AXIS") :  
        SetGadgetColor(#T_zero, #PB_Gadget_BackColor,  $B19474  )
   
     StringGadget(#zeroX,zero_text_x,zero_text_y,zero_text_breedte,zero_text_hoogte,"")
     StringGadget(#zeroy,zero_text_x,zero_text_y+zero_tussen,zero_text_breedte,zero_text_hoogte,"")
     StringGadget(#zeroz,zero_text_x,zero_text_y+2*zero_tussen,zero_text_breedte,zero_text_hoogte," ")
     StringGadget(#zeroa,zero_text_x,zero_text_y+3*zero_tussen,zero_text_breedte,zero_text_hoogte,"")
     LoadFont(#font31,"arial",31, #PB_Font_Bold)   
     SetGadgetFont(#PB_Default, FontID(#font31))
    ; TextGadget(#PB_Any,10,zero_text_y,20,30," X ") 
     
   ; SetGadgetColor(#text2, #PB_Gadget_BackColor, $F4C985  )
   
     
    CloseGadgetList()
  
  EndProcedure
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: confusing with enumerations

Post by Josh »

Look at your constants #home and #zero. Both have the same value and in your code you are producing two gadgets with a gadgetnumber 0.

Deleting your two lines,
#home will get the value 0 and
#zero will get the value 10.

If you want to use more enumerations, you can use named enumerations:

Code: Select all

Enumeration EnumXYZ
   #home: #homeX: #homeY: #homeZ: #homeAll
   #T_home:#T_home_X:#T_home_y:#T_home_z:#T_home_all
EndEnumeration

Enumeration EnumXYZ
   #zero : #zeroX: #zeroY: #zeroZ:  #zeroA
   #T_zero:#T_zeroX:#T_zeroY:#T_zeroZ:#T_zeroA
EndEnumeration
sorry for my bad english
Post Reply