Text in label enclosed with square brackets

Good day,

Something strange with the label. The label, circled in red (Output_ImageCountdown) has square brackets around it. Can someone tell me where this comes from?
It must only display the number.
The value is sent via Bluetooth from a Arduino Nano Sketch as a Integer value. The value can be as big as 128.


From the block name, ReceiveSignedBytes, we can infer that the block is going return multiple bytes, and since bytes are served as numbers in AI2, they will come in an AI2 list.

The [] wrapper is the default conversion in AI2 when taking an entire list and converting it to text.

To avoid the wrapper, do a safety check that the returned list is not an empty list, and select item 1 of the list for display.

1 Like

Thanks.

Is there "ReceiveSignedByte" instead of "Bytes"?
I actually just want to receive one Byte.

Oops.

I just read that parameter name on the ReceiveSignedBytes block, and see how you just asked for 1 byte.

I leave it to you to search through the Blocks pallette for a single byte read. I am not hopeful.

AI2 block pallettes are kept minimal, to avoid overwhelming newbies.

The block you used lacks the smarts to look for a single byte request and to return just that byte. I think that's just as well.

Instead, grab the incoming bytes list into a variable, and wrap that Label assignment with a FOR EACH ITEM IN LIST block over the incoming bytes list, so each item gets assigned into that Label.Text, but you end up seeing only the last item in the list.

Not sure I understand your last paragraph. Do you have a example?

Will something like this work?

This block works, for what I am using it for.
The Ardruino sending a Int to the APP to count down from x value to zero. The countdown is then displayed in the label as expected.

Should you ever need to work with lists, here is my revamped FAQ with an Introductory section:

Thanks @ABG

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.