Announcement

Collapse
No announcement yet.

Reading Userbutton status (momentary Userbutton)

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading Userbutton status (momentary Userbutton)

    Hi all,

    On the setting page, I have a non-momentary Userbutton,(stay pressed when is pressed)

    How can I read the "status" of the Userbutton?

    I will need to add it to an
    " if is 0(released) do this(put here my code)
    else if is 1(pressed) do that? (other bits of code)

    As usual A very big thank you for the help,

    I am using VisiGenie environment

    Best regards
    Emanuel
    Last edited by Emanuel; 15th November 2017, 02:16 AM.

  • #2
    Hi Emanuel,

    This command seems to work and will return a zero when off and a 2 when on.

    test := img_GetWord(hndl, i4Dbutton0, IMAGE_INDEX);

    You will have to change it to your Userbutton id eg iUserbutton0

    I hope this works for you

    Best regards

    Paul

    Comment


    • #3

      Hi Paul, this is exactly what I did, but I get always the same value, for sure I do something wrong as usual!!
      Attached is the code if you please could tell me what is wrong that would be great.

      func MagicEvent47(var fanvar)

      fanvar :=img_GetWord(hndl, iUserbutton1, IMAGE_INDEX);
      if (fanvar := 0)

      to(COM0);
      putstr("M106 S255");
      serout('\n');

      else if (fanvar := 2)

      to(COM0);
      putstr("M106 S0");
      serout('\n');
      endif


      endfunc

      And my best regards
      Emanuel

      Comment


      • #4
        Hi Emanuel,

        Try changing if (fanvar := 0) to if (fanvar == 0) and else if (fanvar := 2) to else if (fanvar == 2)

        I make that mistake on a regular basis

        Paul

        Comment


        • #5
          FANTASTIC!!!!!
          If you give me the name of your Boss, I will personally recommend you for a BIG pay raise LOL
          Thank you so much!!
          All the best
          Emanuel

          Comment


          • #6
            You're very welcome and thank you

            Comment

            Working...
            X