The string type is used for storing text strings. A text string is a sequence of characters in the Unicode format with the final zero at the end of it. A string constant can be assigned to a string variable. A string constant is a sequence of Unicode characters enclosed in double quotes: "This is a string constant".
If you need to include a double quote (") into a string, the backslash character (\) must be put before it. Any special character constants can be written in a string, if the backslash character (\) is typed before them.
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";
To make the source code readable, long constant strings can be split into parts without addition operation. During compilation, these parts will be combined into one long string:
//--- Declare a long constant string 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>"; //--- Output the constant string into log Print(HTML_head); }