GetChar

Category: Script / Strings
Since engine version: 4.9.1.0 GWE

Description

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

Syntax

int GetChar (string szText, int iIndex);

Parameters

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

Remarks

Using Format("%c") the character can be converted back into a string.
Using "string"[index] the character at the position denoted by index can be extracted as a string. Negative indices count backwards from the string end.

Example

var c=GetChar(GetPlayerName(0), 0);
if (Inside(c, 97, 122)) c-=32;
if (Inside(c, 65, 90)) Message("Dein Name beginnt mit dem %d. Buchstaben des Alphabets.", 0, c-64)
Gets the first character of the name of the first player.
See also: Format, GetLength
Sven2, November 2001