Search code examples
syntaxmql4

How to print #property value?


How do I access #property values from the code?

For example I'm having these:

#property description "Foo"
#property copyright   "bar"
#property link        "http://www.mql4.com"
#property version     "1.0"

I've tried to print it as follow:

Print(description);

but I've the error that it's undeclared identifier. Any ideas?


Solution

  • WORKAROUND: You cannot access/retrieve the #property values in MQL (not that I know anyway). However, there is a workaround with #define. For example:

    #define propDescription "Foo"
    #define propCopyright   "bar"
    #define propLink        "http://www.mql4.com"
    #define propVersion     "1.0"
    
    #property description propDescription
    #property copyright   propCopyright
    #property link        propLink
    #property version     propVersion
    

    ... and later, in your code, you can access it with:

    Comment( "Current Version: " + propVersion );
    

    Hope this helps.