Can an EA kill itself as part of the programming? - page 2

 
Irtron:

Missing type specifier is not allowed in MQL4 unlike in other languages. So it definitely doesn't and fails with 'unexpected token' error as expected.


Will, why do you take this so personal? A simple question implies a simple answer. :)

That's what I thought, but it took me three days to figure out why my EA wasn't working correctly and the reason was a missing type on a static had defaulted to int when I wanted a double, but it compiled just fine!


Not personal, your simple question was dumb. I typed a response to a question. Do you always compile and test your responses to make sure their 100% correct? I don't think so.

 
WHRoeder:

Do you always compile and test your responses to make sure their 100% correct? I don't think so.

So you do take this personal. That doesn't help the issue though, no matter what you don't think.

start() {
  static aborted=false;
  if (aborted == true) return;
  ...
  if (...) {
    aborted=true;
    alert(...); // display message once here
  }
  ...
}
Yet again, there is no default type in MQL4 language. This applies to both start() function and static aborted variable that are missing type specifier and cause errors by MQL4 compiler in your example above.
 

void LightHeartedFunctionToRemindPostersThatTheOriginalRequestWasForAnEAToKillItselfAndNotTheProgrammersToKillEachOther()

{

int a = 1/0;

}


CB

 
Irtron:



void commitSuicide()

{
int h = WindowHandle(Symbol(), Period());
if (h != 0) PostMessageA(h, WM_COMMAND, 33050, 0);
}



Interesting. I couldn't find the PostMessageA() function in the MetaEditor search function for the language :-(

Perhaps you are making a WinAPI call direct, using a specific DLL which then needs to be #include'd?


There is also a WindowExpertName() function which returns a string and it is not clear if one could use that in some way. You can apparently delete chart objects by name, but I think I tried

ObjectDelete( WindowExpertname() );

to no effect :-(

 
cloudbreaker:

void LightHeartedFunctionToRemindPostersThatTheOriginalRequestWasForAnEAToKillItselfAndNotTheProgrammersToKillEachOther()

{

int a = 1/0;

}


CB

Well that doesn't compile. I already tried it (yesterday). You can fool the compiler by doing something like


int a=0;

int b=10/a;


which at least is a run-time rather than a compile time error. However it probably just throws an error (= doesn't work.) It doesn't crash the EA thread :-(

 
dabbler:

Interesting. I couldn't find the PostMessageA() function in the MetaEditor search function for the language :-(

Perhaps you are making a WinAPI call direct, using a specific DLL which then needs to be #include'd?


I didn't mention it indeed, sorry.

#include <WinUser32.mqh>


 
dabbler:

Well that doesn't compile. I already tried it (yesterday). You can fool the compiler by doing something like


int a=0;

int b=10/a;


which at least is a run-time rather than a compile time error. However it probably just throws an error (= doesn't work.) It doesn't crash the EA thread :-(

Which part of "LightHearted" did you miss, dabbler? :-)


CB

Reason: