Is there a quick way to convert an ASCII KeyCode to a Char?
i.e.
keycodeToChar(65); //returns "A"
If not, what would be the easiest way of doing this?
I only really need to be able to do it for the alphabetical keys (65-90) if that makes things simpler.
This is for the purpose of generating random letters, so if there's another way of doing this please do let me know!
i think the conversion is implicit.
char c = Random(25) + 65;
Display("%c",c);
edit:
So your function could be:
String CharToString(char c){
return String.Format("%c", c);
}
It's also worth noting that the AGS char type is an unsigned 8-bit type (1 byte). What that means is that:
char c = (255 + 5);
Is the same as:
char c = 4;
It automatically bounds values to the valid range. All of AGS' numeric types do this, but the range is so high that it's typically not even noticeable.
There's an implicit conversion in AGS between any of the integral types (bool, char, short, int, or any enumerated type). Enumerated type variables are actually allowed in AGS to have invalid values as a result of this implicit conversion, but again, that's not likely to cause issues.
So, any of these methods of setting a char are valid:
char A = 65;
char B = 'B';
char C = eKeycodeC;
char D = A + 3;
Thanks guys; just what I needed! :)