quote:
Originally posted by waterbottle
the example said - 1 so I added that too... I also tried without it, still didn't work.
Because, as Plik said, you pass a character as parameter to the function 
charCodeAtTest( n ) in this code:
code:
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
    return '' + charCodeAtTest(Message.charAt(0));
}
because 
charAt(0) will return the first 
character in the string 
Message.
So the parameter 
n in your function 
charCodeAtTest( n ) is a character, not a number...
And a character minus a number (thus your 
n-1) results in error code 
NaN...
And 
charCodeAt() expects a number (character position, starting from 0 for the first character), not 
NaN. Hence why it always return the same number, because your 
n-1 is always 
NaN.
quote:
Originally posted by waterbottle
What I'm trying to do first is get the ascii equivalent of the char. 
for example, ' ' = 32, 'a' = 97, 'b' = 98, 'A' = 65, '1' = 49.
string.char
CodeAt(
character position)
eg:
"ab1def".charCodeAt(0) equals 97
"ab1def".charCodeAt(1) equals 98
"ab1def".charCodeAt(2) equals 49
---
To check for certain bits in a number use the bitwise operators.
eg:
3 & 1   will equal 1
3 & 2   will equal 2
1 | 2    will equal 3
---
PS: in the very first reply in this thread, Felu, gave you a link to the JScript documentation. And later on people gave links to that same online documentation. Plenty small examples are given in those docs.
