Announcement

Collapse
No announcement yet.

Problem reading the button status

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

  • Problem reading the button status

    Hi!
    I'm using visi genie pro.
    I've created a UserButton with 8 images. I've made that because I need a button that can have more the two stable state.
    Now, let me show the question.
    I receive some message from spi that change the button state.
    When someone push the button, I have to do different operation for different states of the button.
    For example, the operation that I have to do when button is on state 2 is different from the operation for the state 3.
    But if I use the ReadObject function to see the button status, it return always one or zero. Also the new value, getted from a magic event linked to the button, is always zero o one.
    There is not possibility to know if the button is in state 3 or 4?
    Pietro

  • #2
    Hi,

    Thank you for posting your concern here.

    Did you see the application note found here:

    ViSi-Genie Blocked Users


    and please use GTX tool to set the block index for you to see how it operates.

    It is applicable for your purpose.



    Please let me know if it solves your concern.

    Best regards,
    Kayven

    Comment


    • #3
      Hi,
      Thank you for reply. In the application note that you have suggested, it isn't explained how you can read the button status from GenieCode.
      Moreover, If you use WriteObject function, to change the button state it doesn't work for states more then 1.
      So, I've done the functions that I need by myself. Here the code:

      Code:
      func MyGetUserButtonStatus(var ObjectIdx)
          var j, k, Objects ;
          Objects := *(oObjects+tUserButton) ;
          j := 2 + (ObjectIdx&0x00FF) * 2 + Objects ;
          k := img_GetWord(hndl, *j, IMAGE_INDEX);
          return k/2;
      endfunc
      
      
      func MyWriteObject(var ObjectTypeAndIndex, var NewVal)
          var i, j, k, Objects, ObjectType,ObjectIdx ;
          ObjectType := (0x3f&(ObjectTypeAndIndex>>8)) ;
          ObjectIdx := ObjectTypeAndIndex&0x00FF;
              if (ObjectType == tForm)
              ActivateForm(ObjectIdx) ;
          else
              Objects := *(oObjects+ObjectType)+ObjectIdx*2+2 ;
              i := *(Objects) ;
              switch (ObjectType)
                  case tUserButton :
                      j := InputControls[oUserButtons[ObjectIdx+1]] ;
                      break ;
                  default : j := -1 ;
              endswitch
              if (j != -1)
                  k := img_GetWord(hndl, i , IMAGE_INDEX) ;
                  NewVal := NewVal << 1 ;
              endif
                  img_SetWord(hndl, i , IMAGE_INDEX, NewVal); // where state is 0 to 2
                  img_Show(hndl, i) ; // will only display if form is current
          endif
      endfunc
      MyGetUserButtonStatus gets %GenieIndex% and returns the button state,
      MyWriteObject gets%GenieIndex% and the button status that you want, to change the showed icon.
      Let me know if you think it's a good solution.

      Regards
      Pietro
      Pietro

      Comment


      • #4
        Hi Pietro,

        Thank you for sharing the code.
        This may help others.


        The other way around is to create an user-defined function.

        Right now, I try to check your code.


        Best regards,
        Kayven

        Comment

        Working...
        X