Very strange: a line of code does nothing despite not being commented

mt4ski
242
mt4ski  

I don't understand at all. How is it possible? 

A line of code calls a function with:

Print("BEGIN")

at the very top.

Below the function call there is: 

Print("FUNCTION WAS CALLED");

The program prints FUNCTION WAS CALLED but NOT BEGIN !


All files are freshly compiled and there is only one function with that name.

Joel Protusada
19599
Joel Protusada  
Did you put a semicolon?
William Roeder
23802
William Roeder  
  1. Post all relevant code. The opening function so we know the context. Your first line won't compile.
  2. If you are printing a lot of lines, the tab will not show all of them. Right Click → Open and look at the file.
mt4ski
242
mt4ski  
Joel Protusada:
Did you put a semicolon?
It wouldn't compile without a semicolon.
mt4ski
242
mt4ski  
William Roeder:
  1. Post all relevant code. The opening function so we know the context. Your first line won't compile.
  2. If you are printing a lot of lines, the tab will not show all of them. Right Click → Open and look at the file.

Everything compiles fine and I confirm the second string isn't printed.

void okay()
{
   strange(); 
   Print("FUNCTION WAS CALLED");
}

void strange()
{
   Print("BEGIN");
   
 // remaining code 
}

okay();

> "FUNCTION WAS CALLED" // output
>
// end of output
Joel Protusada
19599
Joel Protusada  
mt4ski:

Everything compiles fine and I confirm the second string isn't printed.

> "FUNCTION WAS CALLED" // output
>
// end of output

Have you called strange() function?

Keith Watford
Moderator
26757
Keith Watford  
mt4ski:

Everything compiles fine and I confirm the second string isn't printed.

> "FUNCTION WAS CALLED" // output
>
// end of output

Where is

okay();

in your code, seems to be outside of any function.

Is the code compiling?

There is something wrong with your code or positioning of okay(), because if it is inside OnTick(), "BEGIN" will be printed.

mt4ski
242
mt4ski  
Joel Protusada:

Have you called strange() function?

Of course I'm calling the function, otherwise  "FUNCTION WAS CALLED" wouldn't be printed.
mt4ski
242
mt4ski  

Keith Watford:

Is the code compiling?

Like I said already, everything compiles fine. 

okay() seems to be outside of any function.

There is something wrong with your code or positioning of okay(), because if it is inside OnTick(), "BEGIN" will be printed.

Moderator's Note: This post was edited by the OP some time after so at the time Nobody was aware that the okay() function was from a library when replying.

I only posted the relevant code; okay() is called from OnTick(). Edit: Actually, it is called from another function in the same library, which in turn is called from OnTick(), but it doesn't make any difference.

// ----- EA.mq4 -----

#include <MyLib.mqh>

OnTick()
{

   Other_Function();

}

// ----- MyLib.mqh -----

void Other_Function()
{
    okay();
}

Things are much simpler when there's something wrong with my code.

Keith Watford
Moderator
26757
Keith Watford  
mt4ski:

Like I said already, everything compiles fine. 

I just posted the relevant code; okay() is called from OnTick().

Things are much simpler when there's something wrong with my code.

Well, there is something wrong in your code somewhere, because if okay() is called, "BEGIN" will print.

mt4ski
242
mt4ski  
Keith Watford:

Well, there is something wrong in your code somewhere, because if okay() is called, "BEGIN" will print.

You think logically about something that doesn't make any sense. Been there done that.

You can't say there is something wrong with my code when there is obviously nothing wrong with it.

Everybody can see it.