GetChar

Category: Script / Strings
Since engine version: 1.0 OC

Description

Determines the ASCII character code of a character in a string.

Syntax

int GetChar(string text, int index);

Parameters

text:
String of which to get a character.
index:
Position of the character. The first character is at position 0. If the specified position is outside the string, nil is returned.

Remark

Format("%c") can be used to convert the character to a string.

Example

var c = GetChar(GetPlayerName(0), 0);
if (Inside(c, 97, 122)) c-=32;
if (Inside(c, 65, 90)) Log("Your name begins with the %dth letter of the alphabet.", c-64)
Gets the first character of the name of the first player.
See also: Format, GetLength
Sven2, 2001-11