How can I convert text to "number"?

Unlike lower level languages, AI2 has Duck Typing for math operations.

I think he means to convert the text string image

to a number string image

2 Likes

i have the same question. if i put number "1" on the textbox the answer on the label will be converted to "one". "-1" will be "negative one". can you help me guys? thanks

Are you talking about speech output?

Are you complaining about this happening, or are you asking for a way to make this happen?

its good now sir. I already have a solution. thanks

please share the solution here and close this topic. Thank you :innocent:

1 Like

Thank you! This helped me. I was scared that numbers in text strings will be treated like in Small Basic, which means that "100" + "55" = "10055".

1 Like

Although AI2 does an amazingly wonderful job of translating (invisibly) strings-numbers-strings, there still times like when exchanging with Google Charts or Google Sheets (and probably others) that the translation must be made.

:musical_note:Wouldn't It Be Nice :musical_note: (Beach Boys 1966) :musical_note:

WouldntItBeNice

Easy enough....

image

2 Likes

Hello.
I had the problem of receiving data (numbers) from an Arduino trough Bluetooth connection appearing as strings.
The solutions that i found here didn't solved my problem so I've continued researching and i came up with a solution that might help others that may come here too.

I've set a clock to read the data from the bluetooth every second and I've used a label to display the text received from the Bluetooth, because i only needed 4 characters at a time I've used the number 4 in the "number of bytes".
Then i used the label text, that was in fact a number as a string, using the "label.text" block and the data could finally be used as a number for calculations.

1 Like