Print() function truncating very large strings

 

I'm producing some reports in large strings and print them to the terminal and I've noticed that the Print() function with very large strings truncates them after some thousands characters.

For example, this scripts does not print the entire string:


void OnStart()
{
  string tmp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  string str;

  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++)
      str += "\n" + tmp;

  Print(str);
  Print(StringLen(str));
}


The output is the following (identical with both build 4731 and build 4585):


...
...
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRST
270000


The string length is correct and this means that the problem is not in the string but in the implementation of the Print() function. 

I created a custom print function which splits the input string in lines and iterates on the lines and prints them. This function works as expected but I don't want to create my own function to carry out this trivial task.

Is this a know limitation? Is there any setting or workaround to make the Print() function work properly with very large strings?

Thanks for your help!

 
f.pap:

I'm producing some reports in large strings and print them to the terminal and I've noticed that the Print() function with very large strings truncates them after some thousands characters.

For example, this scripts does not print the entire string:



The output is the following (identical with both build 4731 and build 4585):



The string length is correct and this means that the problem is not in the string but in the implementation of the Print() function. 

I created a custom print function which splits the input string in lines and iterates on the lines and prints them. This function works as expected but I don't want to create my own function to carry out this trivial task.

Is this a know limitation? Is there any setting or workaround to make the Print() function work properly with very large strings?

Thanks for your help!

That is true. Print () is limited. Somewhere around 16384, a bit lower, I think. But I dont remember exactly.
 
f.pap: I'm producing some reports in large strings and print them to the terminal and I've noticed that the Print() function with very large strings truncates them after some thousands characters.

Remember that Print() is outputting to the Experts log file, and so you don't really want to have big log files. So, consider outputting to your own text files instead.

 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893