StringGetCharacter

Rend la copie de la chaîne avec la valeur changée du symbole dans la position indiquée.

ushort  StringGetCharacter(
   string  string_value,     // chaîne
   int     pos               // position du symbole dans la chaîne
   );

Paramètres

string_value

[in]  La chaîne.

pos

[in]  La position du symbole dans la chaîne. Peut être de 0 jusqu'à StringLen(text) -1.

La valeur rendue

Le code du symbole ou 0 en cas d'une erreur. Pour la réception du code de l'erreur il faut appeler la fonction GetLastError().

Example:

void OnStart()
  {
//--- delete all comments on the chart
   Comment("");
//--- declare a string, from which we will obtain the values of symbol codes and remember the string length
   string message = "The script demonstrates the operation of the StringGetCharacter() function";
   int    length  = StringLen(message);
//--- declare a string variable, to which we will add the obtained symbols from the demo string
   string text    = "";
//--- in the loop by the demo string length
   for(int i=0i<lengthi++)
     {
      //--- wait 1/10 seconds
      Sleep(100);
      //--- get a symbol from a string located at the loop index in the demo string
      ushort char_code=StringGetCharacter(messagei);
      //--- add a symbol to the displayed string and display the resulting string as a chart comment
      text+=ShortToString(char_code);
      Comment(text);
     }
//--- wait two seconds and remove the comment from the chart
   Sleep(2000);
   Comment("");
   
   /*
   Result: the demo string appears on the screen character by character
   The script demonstrates the operation of the StringGetCharacter() function
   */
  }

Voir aussi

StringSetCharacter, StringBufferLen, StringLen, StringFill, StringInit, StringToCharArray, StringToShortArray