Asc: Difference between revisions
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
//Asc returns an ANSI character code | //Asc returns an ANSI character code | ||
var CapitalA, LowerB; | var CapitalA, LowerB, str; | ||
str = "A is for Apple"; | |||
CapitalA = str.charCodeAt(0); | |||
NSB.Print("Character code for A = " + CapitalA); | NSB.Print("Character code for A = " + CapitalA); | ||
LowerB = | LowerB = "b".charCodeAt(0); | ||
NSB.Print("Character code for b = " + LowerB); | NSB.Print("Character code for b = " + LowerB); | ||
</pre> | </pre> |
Revision as of 05:58, 2 May 2013
Asc(string)
Description
Asc returns the ANSI character code of a character. The required parameter, string, is any valid string expression. If string is longer than one character, only the first character is used.
Example (BASIC)
Rem Asc Example 'Asc returns an ANSI character code Dim CapitalA, LowerB CapitalA = Asc("A is for Apple") Print "Character code for A = " & CapitalA LowerB = Asc("b") Print "Character code for b = " & LowerB
Example (JavaScript)
//Asc Example //Asc returns an ANSI character code var CapitalA, LowerB, str; str = "A is for Apple"; CapitalA = str.charCodeAt(0); NSB.Print("Character code for A = " + CapitalA); LowerB = "b".charCodeAt(0); NSB.Print("Character code for b = " + LowerB);
Output
Character code for A = 65 Character code for b = 98