Variable length?

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Variable length?

Post 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:
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Re: Variable length?

Post 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
User avatar
Ats
Posts: 603
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Variable length?

Post by Ats »

Oh, right !!!!
Thanks, sorry for that :oops:
Post Reply