You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
the function is declared this way
int __stdcall GetValueString( LPCTSTR key, char *value, int valuesize )
where value is a pointer to the string which will hold the returned value and valuesize contains the initial number of characteds allocated from MQL, used to copy the right numbers of characters into value, avoiding overflows.
GetValueString() copies the read string into value including the terminating null characted.
From a MQL expert we use the function this way:
string Value; // Global
....
....
Value = " "; // Fill with 30 spaces
GetValueString( "keyname", Value, StringLen(Value) );
the first time GetValueString() is called, Value will contain the right value, for example "eurusd".
Next time the code is executed the instruction which pads the string with spaces seems to have no effects (the spaces are not assigned), and StringLen() returns 6, the length of the value returned before. Now the available space into the string Value (6 ?) could be insufficient to hold the next read value, which results truncated.
Tried to use different padding characters each time ("XXXXX....", "YYYYY...." etc), and this time the variable Value is assigned. But this is a bad way of doing.
Next I have tried this:
string Value; // Global
....
....
Value = ""; // empty string
GetValueString( "keyname", Value, 30 );
Now Value contains the right value, each time.
But how could it work ? Is a string variable pre-allocated of a fixed size each time is declared ? Otherwise I can't understand how the code above could work with a 'empty' string.
Thanks in advance