error: 4008 not initialized string

To add comments, please log in or register
Peter Williams
442
Peter Williams  
WTL (write to log) contains date / time and case number

case 2047: WTL=WTL+" MH - Enter Monitor Hedge - Ticket # "+ticket_nos; break;
case 20471: WTL=WTL+" MH - Enter Monitor Hedge - Ticket # "+ticket_nos; break;
case 20472: WTL=WTL+" MH - Enter Monitor Hedge - Ticket # "+ticket_nos; break;



write_to_log(20471,"YES");
ticket_nos = NormalizeDouble(MOT[H_index][4],0);    // ticket_nos is an integer
write_to_log(20472,"YES");

I have the above error occurring occasionally and just don't understand why it happens.

I have added my own log file to record the problem.

here is the the log extract

2021 2011.06.27 17:53:23 MH - Monitor Hedge ~ H_index = 5 Ticket # MOT[H_index][4] = 209487977 MOT[0][0] = 5
Location 20471 Unanticipated error: 4008 not initialized string
20471 2011.06.27 17:53:23 MH - Enter Monitor Hedge - Ticket # 209483810
20472 2011.06.27 17:53:23 MH - Enter Monitor Hedge - Ticket # 209487977


I use ticket_nos elsewhere and haven't seen a problem.

I saw a similar reference in the forum http://www.metatrader4.com/forum/2869

Slawa 2007.04.19 10:20

Fixed. Please wait for next build.

This appears to be 4 years ago.

Can anyone suggest why this happens and what solution / work around there maybe

William Roeder
22318
William Roeder  
everywhere in the code you have
string var;
just replace with
string var="var uninitialized!!!!!!!!!!!!!!!!!!!!!!!!!";
and you'll track down the problem quick enough.
Peter Williams
442
Peter Williams  
WHRoeder:
everywhere in the code you have just replace with and you'll track down the problem quick enough.

Yes I had a string which I used to build a comment line - I then joiuned 2 strings A = B + C; and subsequntly found that I had commented out ( // ) areas which I no longer needed and hence the string was not initialized.


Thanks again

William Roeder
22318
William Roeder  
peterhw1:
Yes I had a string which I used to build a comment line - I then joiuned 2 strings A = B + C; and subsequntly found that I had commented out

Exactly. I only use the form string a="initial"; a=a+b; a=a+c; so commenting out anything still works.
void    StrApnd(string &v,   string a,    string b="", string c="", string d="",
                string e="", string f="", string g="", string h="", string i="",
                string j="", string k="", string l="", string m="", string n="")
{   v=StringConcatenate(v, a, b, c, d, e, f, g, h, i, j, k, l, m, n);   return;}

// string a="initial"
// StrApnd(a," additional");
To add comments, please log in or register