StringGetCharacter
Restituisce il valore di un simbolo, che si trova nella posizione specificata di una stringa.
ushort StringGetCharacter( string string_value, int pos ); |
Parametri
string_value
[in] String.
pos
[in] Posizione del simbolo nella stringa. Può essere da 0 a StringLen(testo) -1.
Valore restituito
Esempio:
void OnStart() { //--- eliminare tutti i commenti sul grafico Comment(""); //--- dichiarare una stringa, da cui otterremo i valori dei codici simbolo e ricordare la lunghezza della stringa string message = "The script demonstrates the operation of the StringGetCharacter() function"; int length = StringLen(message); //--- dichiarare una variabile stringa, alla quale aggiungeremo i simboli ottenuti dalla stringa demo string text = ""; //--- nel ciclo della lunghezza della stringa demo for(int i=0; i<length; i++) { //--- attendere 1/10 secondi Sleep(100); //--- ottenere un simbolo da una stringa situata nell'indice del ciclo nella stringa demo ushort char_code=StringGetCharacter(message, i); //--- aggiungere un simbolo alla stringa visualizzata e visualizzare la stringa risultante come commento grafico text+=ShortToString(char_code); Comment(text); } //--- aspettare due secondi e rimuovere il commento dal grafico Sleep(2000); Comment(""); /* Risultato: la stringa demo appare sullo schermo carattere per carattere The script demonstrates the operation of the StringGetCharacter() function */ } |
Vedi anche
StringSetCharacter, StringBufferLen, StringLen, StringFill, StringInit, StringToCharArray, StringToShortArray