256 byte string limit?

 

Hi,

Just wrapping up a script which sends tick data to MySQL database. Successful, but when I went to add some more variables in the string I got the compile error:

'(time_posix INT UNSIGNED NOT NULL, th INT UNSIGNED NOT NULL, dow INT UNSIGNED NOT NULL, date_time VARCHAR(40) NOT NULL, date VARCHAR(10) NOT NULL, time VARCHAR(10) NOT NULL, tick INT UNSIGNED NOT NULL, bid DOUBLE NOT NULL, ask DOUBLE NOT NULL, spread DOUB' - too long string (255 characters maximum allowed) C:\_FX\brokerMT4\experts\scripts\MBSQL_EMAv1.mq4 (109, 13)

Is there a workaround for this problem? Concatenation possibly? 256 bytes not a lot to work with.....

The MySQL "UNSIGNED NOT NULL" for each var takes up a LOT of that 255 limit. Ideally, I have another 20 variables to add, mostly Doubles.

I'd greatly appreciate some solution....

Best regards,

Merlin

 

What is this BS

(time_posix INT UNSIGNED NOT NULL, th INT UNSIGNED NOT NULL, dow INT UNSIGNED NOT NULL, date_time VARCHAR(40) NOT NULL, date VARCHAR(10) NOT NULL, time VARCHAR(10) NOT NULL, tick INT UNSIGNED NOT NULL, bid DOUBLE NOT NULL, ask DOUBLE NOT NULL, spread DOU

That's not valid mql4 code.

The maximum literal string size is 255, for larger you must concatenate.

 
WHRoeder:

What is this BS

That's not valid mql4 code.

The maximum literal string size is 255, for larger you must concatenate.


Thanks. Last line was helpful. The error portion I sent was not MQL4 code, but it was the last part of the MT4 Compile Error statement. It's part of the MySQL Insert code which puts each tick, etc., into the database.
 
William Roeder #:

What is this BS

That's not valid mql4 code.

The maximum literal string size is 255, for larger you must concatenate.

Hello,

I have this same issue, this 256 chars string works:

string eightchars = "mystring";
string concatenated = "";

    for (i = 0; i < 32; ++i) {              // 8 * 31 = 256 chars
        concatenated += eightchars ;
    }


 ObjectSetText(obj_str,concatenated,10,"Verdana",clrSilver);

But past that it doesn't, this 264 chars string does not work:
string eightchars = "mystring";
string concatenated = "";

    for (i = 0; i < 33; ++i) {              // 8 * 33 = 264 chars
        concatenated += eightchars ;
    }


 ObjectSetText(obj_str,concatenated,10,"Verdana",clrSilver);


What way to concatenate do you suggest would work with the 2nd for loop?

I checked these from the doc:

ObjectSetText (no character limit mentioned)
https://docs.mql4.com/objects/objectsettext

StringConcatenate (no character limit mentioned)
https://docs.mql4.com/strings/stringconcatenate

Print (no character limit mentioned)

https://docs.mql4.com/common/print

Comment (2045 limit mentioned)

https://docs.mql4.com/common/print

I tested this which does not work:

string eightchars = "mystring";
string concatenated = "";
string stringsConcat;

for (i = 0; i < 7; ++i) {              // 8 * 7 = 56 chars
    concatenated += eightchars ;
}
stringsConcat = StringConcatenate(concatenated,concatenated,concatenated,concatenated,concatenated,concatenated,concatenated); // 56 * 7 = 392 chars

ObjectSetText(obj_str,stringsConcat,10,"Verdana",clrSilver);
ObjectSetText - Object Functions - MQL4 Reference
ObjectSetText - Object Functions - MQL4 Reference
  • docs.mql4.com
ObjectSetText - Object Functions - MQL4 Reference