Loading ...
Sorry, an error occurred while loading the content.

Re: [mh] ON/OFF Question

Expand Messages
  • Eloy Paris
    ... Right, right, they work everywhere in user code. I use them in user code myself too. But Jim is wondering about their use in libraries. In those they are
    Message 1 of 5 , May 9, 2013
    • 0 Attachment
      On 05/09/2013 12:49 PM, Kevin Robert Keegan wrote:

      > 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.

      Right, right, they work everywhere in user code. I use them in user code
      myself too. But Jim is wondering about their use in libraries. In those
      they are not available for use as things are now (if I understood
      correctly Jim's problem).

      Or are you saying that as things are now, they should be available in
      libraries too?

      Cheers,

      Eloy Paris.-

      > 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
      > <http://00constant.pl> file that defines all of your constants.
      >
      >
      > On Thu, May 9, 2013 at 7:39 AM, Eloy Paris <peloy@...
      > <mailto:peloy@...>> 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
      >
      >


      ------------------------------------------------------------------------------
      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
    • Kevin Robert Keegan
      They should be, I can see in http_server.pl around line 2452 that the constant ON is used, but isn t defined in the file. ... Learn Graph Databases - Download
      Message 2 of 5 , May 9, 2013
      • 0 Attachment
        They should be, I can see in http_server.pl around line 2452 that the constant ON is used, but isn't defined in the file.
      Your message has been successfully submitted and would be delivered to recipients shortly.