Multi-line strings in MQL

 
Just curious, how would you do it if not through including a separate file as a string? It kinda bugs to write the quotes all over while writing SQL statements.
 
Nelson Wanyama:
Just curious, how would you do it if not through including a separate file as a string? It kinda bugs to write the quotes all over while writing SQL statements.

a single \ like

#define ForEachSymbol(symbolü,i)  string symbol_=SymbolName(0,true);   \
   int os_total=SymbolsTotal(true);                                  \
   for(int i=1;i<os_total;i++,symbol_=SymbolName(i,true))

(not tested)

 
Nelson Wanyama:
Just curious, how would you do it if not through including a separate file as a string? It kinda bugs to write the quotes all over while writing SQL statements.
//--- 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);
  }


https://www.mql5.com/en/docs/basis/types/stringconst

this is a good example

Documentation on MQL5: Language Basics / Data Types / String Type
Documentation on MQL5: Language Basics / Data Types / String Type
  • www.mql5.com
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...
 
Sardion Maranatha:


https://www.mql5.com/en/docs/basis/types/stringconst

this is a good example

The quotations 🤦‍♂️
 
Carl Schreiber:

a single \ like

(not tested)

This method works. Just not for strings