文字列型は、テキスト文字列を格納するために使用されます。テキスト文字列は、ゼロで終わる Unicode 形式の文字列です。文字列定数は、文字列変数に割り当てることが出来ます。文字列定数は、”これは文字列定数です” のように二重引用符で囲まれた Unicode 文字の配列です。
文字列に二重引用符( ” )を含む必要がある場合は、その前にバックスラッシュ( \ )を置かれなければなりません。特別文字定数はバックスラッシュ文字( \ )が前に入力された場合文字列で記述することが出来ます。
例:
string svar=“This is a character string” ;
string svar2=StringSubstr (svar,0,4);
Print (“Copyright symbol\t\x00A9” );
FileWrite (handle,“This string contains a new line symbols \n” );
string MT5path=“C:\\Program Files\\MetaTrader 5” ;
ソースコードを読みやすくするために、長い定数文字列は、加算演算なしで分割することが出来ます。コンパイル時に、各部分は1つの長い文字列に結合されます。
//— 長い文字列定数を宣言する
string HTML_head=“<!DOCTYPE html PUBLIC \”-//W3C//DTD XHTML 1.0 Transitional//EN\””
” \”http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\”>\n”
“<html xmlns=\”http://www.w3.org/1999/xhtml\”>\n”
“<head>\n”
“<meta http-equiv=\”Content-Type\” content=\”text/html; charset=utf-8\” />\n”
“<title>Trade Operations Report</title>\n”
“</head>” ;
//— 文字列定数をログに出力する
Print (HTML_head);
}
Originally posted 2019-07-27 09:48:52.
0 people found this article useful
This article was helpful
This article was helpful
0 people found this article useful