Question: WORKING WITH LIBRARIES

 

Hello everyone,

I want to tidy up my EAs and store my functions in libraries.

Example:

EA contains this:

extern int loglevel = 1;

int start() {

[...]

Log(1, "Important message, like errors and stuff");

[...]

Log(0, "Warnings, Infos etc.");

[...]

return(0);

}

The library contains the log-Function:

void Log(int level, string txt){

if (level>=loglevel) Print(txt);

return;

}

However I get the following error when compiling the library:

'loglevel' - variable not defined C:\Programme\MetaTrader 4\experts\libraries\MainLib.mq4 (38, 15)


My question: is it possible, to use a system variable of an EA in an extern library without passing it all the time?


 

easiest way is to #include filename.mqh

that source line will be replaced by the source text in the "library" at compile time.

 
thought so... thanks!
Reason: