Hi experts,
I am currently trying to get my first function to be compiled. But I got some error.
any idea how to fix them?
I created 2 mqh files and want the second file calling the struct of first to make a function.
Thank in advance,Kittamet
Thank in advance
This line:
ArrayResize(ok,5);
Cannot be in global scope. Place it within the function that requires it.
still got error in test.mqh
thank you
Then add this line into test2.mqh (after line #include):
struct ex;
That's "forward declaring" the structure that will be defined later.
Then add this line into test2.mqh (after line #include):
That's "forward declaring" the structure that will be defined later.Thank you very much
compiler now have no error.
Hi experts,
I am currently trying to get my first function to be compiled. But I got some error.
any idea how to fix them?
I created 2 mqh files and want the second file calling the struct of first to make a function.
Not sure about your logic or context, but does it work ok if you just run the whole code from the one file, thats your first step...?
If you're just trying to alter the values of the struct members there are probably easier ways...
struct ex{ int a,b; void ex1(int i,int j){a+=i;b+=j;} }; ex ok[]; void OnInit(){ ArrayResize(ok,5); ok[1].ex1(10,20); }
or even
struct ex{ int a,b; }; ex ok[]; void OnInit(){ ArrayResize(ok,5); ok[1].a+=10;ok[1].b+=100; }
Personally I don't use include files anymore, because the auto-complete and function find features of the editor are of no use when you're working between files.
Not sure about your logic or context, but does it work ok if you just run the whole code from the one file, thats your first step...?
If you're just trying to alter the values of the struct members there are probably easier ways...
or even
Personally I don't use include files anymore, because the auto-complete and function find features of the editor are of no use when you're working between files.
Hi,andrew
you are right.if these code are assembled to a script. this problem will not happen.
I am trying to create any include and then linking in to one for easy understading and editing.
The code will be seperated to part by part that work uniquely.I have seen too many delevoper do like this , but I dont know what it is. I just learning

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi experts,
I am currently trying to get my first function to be compiled. But I got some error.
any idea how to fix them?
I created 2 mqh files and want the second file calling the struct of first to make a function.
Thank in advance,Kittamet
Thank in advance