Cast string to number

Hey!

I am reading a calendar event with the ical binding into a string variable.
Specifically i plan to use it to schedule the soc of my ecar. so the String contains a number between 0 and 100.
I found a few threads that suggested using a switch case and a proxy variable but for 100 values this would be tedious.

Is there another way?

Thank you!

I remembered there’s a thing called chat GPT.
Here’s the answer:

val Number convertedNumber = Integer::parseInt(YourStringItem.state.toString)

If that line works, You can just make YourStringItem be a Number Item instead it will be converted to a Number automatically.

1 Like

You are right.
I thougt it was impossible to map a calendar entry to number directly but it works just fine!