How can I convert char to int so that A would become 64 etc...
Or is it even possible?
I'm thinking of reading numerical data from a file and 8-bit values would be enough for me and it would create unneccasary overhead in the file if I would use 32-bit values there. So I'm thinking I would read them in as char array an use them from there with conversion.
edit:
Or maybe I could read them in groups of fours and then separate them with bitwise operators, but script language doesn't have those?
If it's a variable of char type, it's compatible with integer arimetic already.
For example:
char BLAH = 'A'; //SAME as doing char BLAH = 64;
int ttt;
ttt = BLAH * 2;
Display ("%c, %d, %d", BLAH, BLAH, ttt); //should print out "A, 64, 128"
Note single quoted character (like 'A') means char value (which is actually a 1-byte integer) while double quoted ones (like "A") is a string/String, which is different.
To get the say, 4th character of a String into the char type, you may do something like:
String HA = "MWAHAHA!";
char BLAH = HA.Chars[3]; //index starts at 0
Ok, I'll try that soon and see how it turns out.
Thanks
Quote from: zabnat on Thu 31/08/2006 08:39:42Or maybe I could read them in groups of fours and then separate them with bitwise operators, but script language doesn't have those?
AGS supports >>, <<, &, | and ^.
http://www.adventuregamestudio.co.uk/manual/Operators.htm
Don't put character 0 into a String, though, as it will mess it up.
Errmmm...I guess I'm being kind of nit-picky with this...but...A is 65, not 64...
[EDIT:]
ASCII keycode table (http://www.adventuregamestudio.co.uk/manual/ASCIIcodes.htm)