Page 1 of 1

Global enumeration of named

Posted: Wed Jun 26, 2013 4:35 pm
by User_Russian
This is necessary to generate unique numbers for objects such as windows, gadgets, files, images, etc.
This requires the reserved names for all objects, which to be global (for example: Window, Gadget, File, Timer etc).

Code: Select all

Enumeration Window
  #Window
EndEnumeration


DeclareModule x
Enumeration Window
  #Window
EndEnumeration
EndDeclareModule

Module x
  
EndModule

Debug #Window
Debug x::#Window ; Must be 1.

Re: Global enumeration of named

Posted: Mon Jul 01, 2013 5:42 pm
by ts-soft
+1

like this, fullqualified:

Code: Select all

 DeclareModule Common
  Enumeration Gadgets
    #btn_1
    #btn_2
  EndEnumeration
EndDeclareModule

Common::Enumeration Gadgets
  #btn3
EndEnumeration

Debug #btn3 ; should 2 

Re: Global enumeration of named

Posted: Mon Jul 01, 2013 5:46 pm
by User_Russian

Code: Select all

DeclareModule Common
  Enumeration Gadgets
    #btn_1
    #btn_2
  EndEnumeration
EndDeclareModule

Enumeration Common::Gadgets
  #btn3
EndEnumeration

Debug #btn3 ; should 2

Re: Global enumeration of named

Posted: Mon Jul 01, 2013 5:54 pm
by ts-soft
thx :D , works fine

Re: Global enumeration of named

Posted: Mon Jul 01, 2013 6:06 pm
by User_Russian
But the drawback of this method is that you need to know the exact name of the module.

It is better if it had special names like PB_Enum_Window, PB_Enum_Gadget, etc, which were reserved names and would be's global throughout the code, including the modules.

Code: Select all

DeclareModule Common
  Enumeration PB_Enum_Gadget
    #btn_1
    #btn_2
  EndEnumeration
EndDeclareModule

Enumeration PB_Enum_Gadget
  #btn3
EndEnumeration

Debug #btn3 ; should 2