Question: WORKING WITH LIBRARIES

To add comments, please log in or register
schnappi
248
schnappi  

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?


Ray
2646
Ray  

easiest way is to #include filename.mqh

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

schnappi
248
schnappi  
thought so... thanks!
To add comments, please log in or register