If the integer value is between 0 and 9, then add a "0" to the beginning of a text variable containing the integer value as text.
if it is within -9 and -1, you can do the same thing. You would just need to add "-0" and use the absolute value of the integer.
So you got:
value = your integer value
text = conversion of value to text
if
0 <= value <= 9
then
text = Combine "0" and text
You just need one condition to check and see if the number is less than 10. If you plan on using this notation quite a lot in your map, you can define a simple function that will do this automatically and return a string or text.
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
Answering your question, yes. But you might need to use custom script to buffer the variable 's', as I don't think GUI supports the % operator (Assuming you're working with GUI).
Another method is to pad your string with zeros until it matches your desired length. This is my preferred method (It's much cleaner IMO). We can avoid having to use / and % to break up the digits by doing this.
inti=10;strings=IntegerToString(i);//Lets say we want the string length to be 4while(StringLength(s)<4){s="0"+s;}Setdialogtext(StringToText(s));
I want to display 01 instead of just 1 in a dialog label when converting an integer to text. Is it possible without alot of IFs?
If the integer value is between 0 and 9, then add a "0" to the beginning of a text variable containing the integer value as text.
if it is within -9 and -1, you can do the same thing. You would just need to add "-0" and use the absolute value of the integer.
So you got:
value = your integer value
text = conversion of value to text
if
0 <= value <= 9
then
text = Combine "0" and text
@Skoite: Go
Yeah, it's actually really easy.
Otherwise, just do something like this:
You just need one condition to check and see if the number is less than 10. If you plan on using this notation quite a lot in your map, you can define a simple function that will do this automatically and return a string or text.
Challenge accepted:
Answering your question, yes. But you might need to use custom script to buffer the variable 's', as I don't think GUI supports the % operator (Assuming you're working with GUI).
Another method is to pad your string with zeros until it matches your desired length. This is my preferred method (It's much cleaner IMO). We can avoid having to use / and % to break up the digits by doing this.