StringGetCharacter
文字列の指定された位置にあるシンボルの値を返します。
ushort StringGetCharacter(
string string_value,
int pos
);
|
パラメータ
string_value
[in] 文字列
pos
[in] 文字列内でのシンボルの位置( 0〜StringLen(text) -1 )
戻り値
例:
void OnStart()
{
//--- チャート上のすべてのコメントを削除する
Comment("");
//--- 文字列を宣言し、そこからシンボルコードの値を取得して文字列の長さを記憶する
string message = "The script demonstrates the operation of the StringGetCharacter() function";
int length = StringLen(message);
//--- デモ文字列から取得したシンボルを追加する文字列変数を宣言する
string text = "";
//--- デモ文字列の長さによるループ
for(int i=0; i<length; i++)
{
//--- 1/10 秒待つ
Sleep(100);
//--- デモ文字列のループ インデックスにある文字列からシンボルを取得する
ushort char_code=StringGetCharacter(message, i);
//--- 表示された文字列に記号を追加し、結果の文字列をチャートのコメントとして表示する
text+=ShortToString(char_code);
Comment(text);
}
//--- 2秒待って、チャートからコメントを削除する
Sleep(2000);
Comment("");
/*
結果:デモ文字列が 1 文字ずつ画面に表示される
The script demonstrates the operation of the StringGetCharacter() function
*/
}
|
参照
StringSetCharacter、StringBufferLen、StringLen、<li6 >StringFill、StringInit、StringToCharArray、StringToShortArray