Android Question problem with sender and array

3394509365

Active Member
Licensed User
Longtime User
Good evening everyone, I use this code, I press the btn to send a message midi and everything works fine:
Code:
B4X:
Sub ButtonSendMessage_Click
ButtonSendMessage.Tag = ArrayAsByte(0x0B,CanB,0x00,VAL2,0x0B,CanB,VAL3,VAL4,0x0C,CanC,VAL5,0x00)' in hex Roland xp 50Dim B AsButton = SenderDim Msg() AsByte = B.TagDim i AsIntFor i = 0To3
Msg1(i) = Msg(i)
Msg2(i) = Msg(i+4)
Msg3(i) = Msg(i+8)Next

Main.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg1,Msg1.Length,0)' fuonzionanoMain.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg2,Msg2.Length,0)
Main.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg3,Msg3.Length,0)
But I need not press the button because I want to do by turning the button into a routine.

Define array ButtonSendMessage.Tag but does not work as I do?
 

stevel05

Expert
Licensed User
Longtime User
I'm not sure I understand the question correctly, but if you're not triggering a button event, you won't get the relevant sender object. You will need to pass the array to the function:

B4X:
Sub SendMessage(Msg() As Byte)
Dim Msg1(4),Msg2(4),Msg3(4) As Byte
Dim i As Int
For i = 0 To 3
    Msg1(i) = Msg(i)
    Msg2(i) = Msg(i+4)
    Msg3(i) = Msg(i+8)
Next

Main.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg1,Msg1.Length,0)'fuonzionanoMain.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg2,Msg2.Length,0)
Main.MidiUSBMan.Connection.BulkTransfer(Main.MidiUSBMan.OutEndPoint,Msg3,Msg3.Length,0)
 
Upvote 0
Top