Is there an easy way to cast an integer as a string. I noticed that casting isn't allowed. I want to read a keyboard code and save it as the corresponding letter as a string. I don't want to have to write a function
if (keycode == 65)
str = "A";
else if...
I couldn't find anyting in the help file or searching this forum so I think I already know the answer but if anyone else knows a shortcut I would be happy to hear it.
Steve O.
i think StrFormat("%d",integer) would do that
I tried that, it just put the number into the string instead of the letter.
I just readed the first line, sorry.
QuoteIs there an easy way to cast an integer as a string.
Then the only thing i can think of is using StrSetCharAt, maybe:
function CharToString(string letter, char keycode){//you can use an int here instead of a char i think
StrCopy(letter,"x");
StrSetCharAt(letter,0,keycode);
}
But there must be another neater way to do it, which somebody will tell you ;) (im not sure even if that way would work)
Yep, Proskrito has the right idea.
Also the same using StrFormat:
string letter;
StrFormat(letter, "%c", keycode);
or for adding a sequence of codes:
StrFormat(letter, "%s%c", letter, keycode);
-Cheers