Page 1 of 1

Variable length?

Posted: Fri Feb 04, 2022 2:01 pm
by Ats
Hi everyone,
I'm currently working on a high score table for Omeganaut, and I have a new basic question:

Is there a simple way to get the length of a string var?
And what about the length of an int?

Thanks for your insights :wink:

Re: Variable length?

Posted: Fri Feb 04, 2022 4:25 pm
by Kjell
Hi Ats,
Ats wrote: Fri Feb 04, 2022 2:01 pmIs there a simple way to get the length of a string var?
Sure, just use length()

Code: Select all

string myString = "Hello";
int myStringLength = length(myString);
Ats wrote: Fri Feb 04, 2022 2:01 pmAnd what about the length of an int?
Same thing, just convert your int to a string first before using length()

Code: Select all

int myInt = 12345;
int myIntLength = length(intToStr(myInt));
K

Re: Variable length?

Posted: Fri Feb 04, 2022 4:45 pm
by Ats
Oh, right !!!!
Thanks, sorry for that :oops: