Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 890

 
rapid_minus:


Thank you, but that's not quite what you need. You have several closing conditions for one magician, but you need the opposite.

This is how I came up with it:

Will it work? Or what is wrong?

It's... How can I put this delicately...

What'sthe switch for, if the code is for one magician?

But you could use ifs if you like, but we'd have to think about conditions.

For example

if ((OrderMagicNumber()==10011&&10033)&&(...)

wouldn't it be blamed at compile time?

 
evillive:

This is... How can I put it gently...

What's the switch for then, if the code is for one magician?

Maybe I don't understand the switch, but in its expression there is one magician, which is compared to several variants of closing conditions.

ZS: saw the sequel. I haven't compiled it yet as I haven't finished the code. Numbers can't be enumerated using an AND operation?

Then how do I get out of it? Repeat for each magician?

ZZZY: Actually, it's not AND, but OR.

 
rapid_minus:

Then how do you get out of it? Repeat it for every wizard?

Yeah.


And about a switch still you should read a primer, there on the contrary, any number of variants is processed (case 0:..., case 1:..., case N:..., where number = value of a magician). I was too lazy to write in the example, so I only had enough time to write two magicians and the default variant ;)

 
evillive:
Yeah

I guess you don't have to write out the OR for each magician after all?
 
rapid_minus:

I guess you don't have to write out an OR for each magician, do you?
We should, Fedya, we should (c)
 
evillive:

Yeah.


And still read a primer about a switch, there on the contrary, any number of variants is processed (case 0:..., case 1:..., case N:..., where number = value of a magician). I was too lazy to write in the example, so I only had enough time to write two magicians and the default option ;)

Thanks for the clarification of the switch. I misunderstood it.
 

And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.

The only question is which variant will eat more bits.

 
rapid_minus:

And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.

The only question is which variant will eat more bits.

Did I miss something - are we optimizing the code already?
 
rapid_minus:

And yet in the switch you get the same repetition of the same closing condition for different mages as you do with ifs.

The only question is which variant will eat more bits.

This is the same branching as if(), it just looks neater and is easier to code if there are three or more single choices of integers to choose from. If there are only two options, or if non-numeric expressions are being compared, then only if(). And by if() you can combine several options (if( option1 && option2 || option3 ) {action;}), while in switch you cannot directly, only one at a time.

switch
if()
switch (x)
{
case 1: Act according to variant 1; break;
case 2: action on option 2; break;
case 3: action on option 3; break;
default: default action; break;
}
if( case1 ) { action in case 1; }
else if( option2 ) { actions by option 2; }
else if( option3 ) { actions by option 3; }
else { default action; }
 
Good afternoon! Always after disabling and enabling"Allow EA to trade" a position opens that should not open. I assume that this is because the variables are not reset. How can I enable or disable "Allow EA to trade" and reset all the variables, as they are after restarting the MT4 platform?
Reason: