From: Kevin R. K. <ke...@kr...> - 2013-05-09 16:49:38
|
The constants defined in mh should be available everywhere, I just confirmed that ON and OFF work in a user script. I have no reason to think they wouldn't work everywhere. If you are trying to define your own constants, placing use constant LATCH => 2; at the top of a user file should work. User files are merged into one large file at runtime so the constants would be available to all other user files. The only caveat being that user code files are combined in alphabetical order. So you may want to create a 00constant.pl file that defines all of your constants. On Thu, May 9, 2013 at 7:39 AM, Eloy Paris <pe...@ch...> wrote: > Hi Jim, > > On 05/08/2013 11:03 PM, Jim Duda wrote: > > > In my user code, I can use the ON/OFF constants like this: > > > > set $side_porch ON; > > > > Where are these constants defined? > > They are defined in sub setup() in bin/mh. This is all of them: > > use constant; # To keep perl2exe happy > use constant ON => 'on'; > use constant OFF => 'off'; > use constant DIM => 'dim'; > use constant BRIGHTEN=> 'brighten'; > use constant TOGGLE => 'toggle'; > use constant STATUS => 'status'; > use constant OPEN => 'open'; > use constant CLOSE => 'close'; > use constant OPENED => 'opened'; > use constant CLOSED => 'closed'; > use constant MOTION => 'motion'; > use constant STILL => 'still'; > > > I want to use these same constants in some library .pm code, not sure > how best to handle that. > > > > I've been using this, which works: > > use constant; > > use constant ON => 'on'; > > use constant OFF => 'off'; > > use constant PIO => 0; > > use constant SENSE => 1; > > use constant LATCH => 2; > > > > Unfortunately, I have to copy this set of code into each and every > Package I want to use them in. > > > > There must be a better way .... > > Given that they are defined in bin/mh, it seems normal that libraries do > not inherit them. > > I guess a better way could be to declare these constants in an object > that gets inherited by pretty much all other objects, like Generic_Item. > > Cheers, > > Eloy Paris.- > > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and > their applications. This 200-page book is written by three acclaimed > leaders in the field. The early access version is available now. > Download your free book today! http://p.sf.net/sfu/neotech_d2d_may > ________________________________________________________ > To unsubscribe from this list, go to: > http://sourceforge.net/mail/?group_id=1365 > > |