There is no try, only fail

 
Try Catch is a pretty standard feature of programming languages. I don't need to justify why it is important or useful, I'm just making the note here for anyone searching for documentation on "mql try" that it doesn't exist.
 
Matthew Colter:
Try Catch is a pretty standard feature of programming languages. I don't need to justify why it is important or useful, I'm just making the note here for anyone searching for documentation on "mql try" that it doesn't exist.

There was discussion about that on Russian forum, it seems Metaquotes don't want to include them, not really sure why.

 
Why don't you make your "TryCatch" yourself like:


#define foreach(_I,all) int _I= all; while(_I-->0)
#define TryContinue(_TRY) ResetLastError(); if (!_TRY) { continue; }

void OnStart() {
   
   foreach(o,OrdersHistoryTotal()) {
      TryContinue( OrderSelect(o,SELECT_BY_POS,MODE_HISTORY) );
      Comment(OrderTicket(),", ",OrderSymbol(),", ",OrderOpenTime());
      DebugBreak();
   }

    DebugBreak();
   
}

As easy to read as a short story. ;)

(But as 'within' the #define the int var. is declared you can use it only once in a function or method.!
 
Carl Schreiber:
Why don't you make your "TryCatch" yourself like:


int _I;
#define foreach(_I,all) int _I= all; while(_I-->0)
bool _TRY;
#define TryContinue(_TRY) ResetLastError(); if (!_TRY) { continue; }

void OnStart() {
   foreach(o,OrdersHistoryTotal()) {
      TryContinue( OrderSelect(o,SELECT_BY_POS,MODE_HISTORY) );
      Comment(OrderTicket(),", ",OrderSymbol(),", ",OrderOpenTime());
   }
}

As easy to read as a short story. ;)

You are hilarious :) do you have any funny ways for creating async  methods?
 
Matthew Colter:
You are hilarious :) do you have any funny ways for creating async  methods?

I just shortened my suggestion.

But what do you mean: "do you have any funny ways for creating async  methods?"

 
Carl Schreiber:
I just shortened my suggestion.
XD  nice

Try catch is a way to short circuit error state checking,  where you try to do the common process first and if it doesn't work then you check for edge conditions that you can recover from.  So when you're in some execution loop,  you won't waste time checking for conditions that only exist in the first and or last iteration.
 
I know try-catch as well as foreach from Powershell. But #define is not creating async methods!
 
Carl Schreiber:
I know try-catch as well as foreach from Powershell. But #define is not creating async methods!
Check this out ;) http://www.ossp.org/pkg/lib/ex/
 
Please use the link button (control-K.) for links Use
the link button See the difference: http://www.ossp.org/pkg/lib/ex/
Reason: