Good Afternoon Monks,

I have a program that uses Win32-Serial and I am sending commands to a receiving decoder which is installed into a model railroad locomotive. Individually the commands work: Ring the bell, blow the horn etc. However, when each command is sent it shuts off the previous command. Below is my code and what I need to be able to do is for example: Lights On stays on even if Bell On is selected. The receiver/decoder does not store commands...it just executes what is sent.

### LIGHTS ON/OFF CODE### sub leftefzeroone { $button53->configure(-text => 'F0 - Left Lights On'); $button53->bind('<ButtonPress>', \&leftefzerotwo); my $tlightson = "<f 1108 144>"; $port->write($tlightson); $port->lookclear(); } sub leftefzerotwo { $button53->configure(-text => 'F0 - Left Lights Off'); $button53->bind('<ButtonPress>', \&leftefzeroone); my $tlightsoff = "<f 1108 128>"; $port->write($tlightsoff); $port->lookclear(); } ### BELL ON/OFF CODE### sub leftefoneone { $button54->configure(-text => 'F1 - Left Bell On'); $button54->bind('<ButtonPress>', \&leftefonetwo); my $tbellon = "<f 1108 136>"; $port->write($tbellon); $port->lookclear(); } sub leftefonetwo { $button54->configure(-text => 'F0 - Left Bell Off'); $button54->bind('<ButtonPress>', \&leftefoneone); my $tbelloff = "<f 1108 128>"; $port->write($tbelloff); $port->lookclear(); }

As you can see from the code the number 128 is the byte number in the receiver/decoder that shuts any function ON to OFF. What I need to implement is a type of IF EXISTS statement. I'm lost as to where to begin on that. I can do simple IF FILE EXISTS type of routines. Thanks in advance!


In reply to Saving Options by PilotinControl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.