Skip to first unread message

Busz Brown

unread,
Jan 17, 2018, 11:42:00 AM1/17/18
to MIT App Inventor Forum

I am using a label to receive data via a BLE device. The data comes into the label fine. What I would like to do is delete it so I can get another data request. I can "Clear" the data by making a button and setting the text to BLANK. It clears the data but when I receive the next data burst the original appears also. I would like it be able to actually delete it so the next data is the only thing that appears.
Thanks

Chris Ward

unread,
Jan 17, 2018, 11:51:48 AM1/17/18
to MIT App Inventor Forum
Hi Busz

If you have cleared the label (which is unnecessary, since setting text in a label simply replaces anything that's already there) yet the original value re-appears, it is most likely because it's actually in the next data.

I suggest testing data received by appending the data to a file - that way, every data burst will be recorded and you can examine the file (on your PC) to see what is sent.

Busz Brown

unread,
Jan 17, 2018, 2:48:24 PM1/17/18
to MIT App Inventor Forum
Hey Chris,
That is what I see when I watch the vids. The text coming in is replacing the text already on the screen. My label acts like a text box. When connected to Hyper Terminal with the BLE I can type and type with CR's and it just keeps going like it's notepad. I will try what you suggest and see if I can figure something out. 
Thanks

Ghica

unread,
Jan 18, 2018, 1:28:00 PM1/18/18
to MIT App Inventor Forum
Post the block that sets the data in your label. Maybe we can point out what you should do to get what you want.
Most likely you were using a join of the content in the label with the new content to set the data in the label. Take out the join.
Cheers, Ghica.

Busz Brown

unread,
Jan 19, 2018, 11:48:39 AM1/19/18
to MIT App Inventor Forum
Hello Ghica,
Here is a snap of the blocks. I am not a programmer (but trying lol), so if I am going about this all wrong feel free to let me know. It does work and I do receive the data from the BLE. But it just won't forget it unless I close the app and reopen it. Then the first string comes in. But the next string comes in and just goes on top of the old string so they are both there. 
Busz
ClearLabelBlocks.jpg

Ghica

unread,
Jan 19, 2018, 12:03:01 PM1/19/18
to MIT App Inventor Forum
Hi Busz,
It is pretty clear what the problem is. You have a list: incomingText. Each time you receive text, you add an item to that list.
Then, you set the text of the label to a string representation of the whole list, removing the ( and ). Therefore, you set all text you ever received in the label.

Instead, you could do: set Label2.Text to get stringValues

I am not sure, maybe stringValues is a list? In that case you could remove the ( and ) as you did using global incomingText, use StringValues instead.

Cheers, Ghica.

Busz Brown

unread,
Jan 22, 2018, 7:46:22 AM1/22/18
to MIT App Inventor Forum
Ghica,
Thank you. I tried what you said and it worked exactly like you said. It did replace as new data came in. The text I am receiving however sends a "burst" for lack of better terminology and I see all the letters scroll by as if each one is replacing the other and when it's all done I am left with the last letter. If it's not one thing it's another ... lol. 

Ghica

unread,
Jan 22, 2018, 11:21:07 AM1/22/18
to MIT App Inventor Forum
If you know what the last letter should be, for example if your BT device sends a line-end at the end or some other marker, then you could collect your data in a string, using a text join (join the text you have with new, just received text), and  only replace the text in your label when you have received everything.
Do you have an example string of what you are receiving?

Cheers, Ghica.

Busz Brown

unread,
Jan 24, 2018, 2:41:17 PM1/24/18
to MIT App Inventor Forum
Here is a screen shot of what is received when I send the data from the unit with the BLE device. The label is the bottom portion of the capture. It all comes in at once (appears anyway) but when I switched it with what you suggested earlier you could see it scroll by (1 character in the label changing as it is being received). If I request data from the device again I will get the fist data AND the second data. Maybe I should look into some how deleting the "List" and the Label ?? 

Screenshot_20180124-143450.png

Ghica

unread,
Jan 24, 2018, 3:50:44 PM1/24/18
to MIT App Inventor Forum
Busz,
You should solve the mystery first about what your device is really sending. Only if you know that you can design a strategy to receive it properly and after that, display it as you like.
So, gather some examples of the text you send from the device, and post the blocks as you have them now.
Cheers, Ghica.
Reply all
Reply to author
Forward
0 new messages