Hello everyone, I have such a problem, for example, if the button is pressed, then the timer is activated and sends text to the textbox separately for 100 milliseconds, for example, if you write 12345 bluetooth sends "1" 100 milliseconds "2" 100 "3" 100 "4" current. And now I need every 200 milliseconds bluetooth should send 2 letters "12" "34" I was playing but it gives me an error
I changed the location 1 to 2 to make it work what needs to be doneif length(TextBox4.Text) > 1 + index then
send text segment ... length(2)
set global index to global index + 2
Try like this (replace my label blocks with your bluetooth blocks):
The main change is for index to be less than length of textbox, not less than or equal to. This fixes your error.
You might consider an alternate method:
(Note for Android < 10 you will need to remove the extra empty first item of the list created by split by)
Thank you all for your hard work, but I'm new to this, can you show it in blocks please
please help me
The original request for sending 2 characters at a time did not mention the corner case of what to do with an odd number of characters:
- Send only pairs of characters and wait for pair completion, or
- Send pairs up to the last single character and send that alone?
I took the first choice, for lack of direction, and based on your use of a TextBox for the input, so I assumed you might be typing additionaal characters into the TextBox.
But now you have switched to a Label, so I am guessing you want to send the odd last character too?
If so, the segment() block needs to adjust its length based on how close the index variable has come to the length of the .Text value.
I'll give you some time to think about this and try things.
These blocks are missing from your Button.Click event
(split at block is "empty")
Change these blocks to look like this in your Clock Timer event:
(as I previously said you need less than, NOT less than equal to)
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)
In your code I see
instead of
Can you understand what Dora Paz wrote? Do you tell the> sign from the => sign?
Yes, sorry, i forgot to change the label blocks to bluetooth blocks as well.
Solution was based upon your original blocks.
What do you mean by sending 2 ? Two individual texts, or each set of two texts sent together as one?
If you want to send pairs then change these blocks in your clock timer event:
This will not work for an odd number of items in your tbNumber list. for that you will need to test for even/odd and handle the odd item (e.g. add a 0/zero, or exclude it).
yes, each set of two texts is sent together as one. For example: write "12345678".
then first "12" 200 milliseconds, then "34" and so on. And I have a question, if you send "123", then send "12", but "3" does not send? Is it possible in this case to bind one character at the end and send as "12" and "3 *", how can the application understand how it is and determine how it can be implemented