|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
|
|
LinkBack | Thread Tools |
|
|
||||
|
||||
|
Quote:
//+------------------------------------------------------------------+ //| Exteranl functions 1 .mq4 | //| Copyright Coders Guru | //| http://www.metatrader.info | //+------------------------------------------------------------------+ #property copyright "Copyright Coders Guru" #property link "somewhere" #import "mylib.ex4" int MyExtFunction(int value,int value2); #import //+------------------------------------------------------------------+ //| script program start function | //+------------------------------------------------------------------+ int start() { //---- int result = MyExtFunction(10,20); Alert ( result); //---- return(0); } //+------------------------------------------------------------------+ In the code above to use an external function resides in a MQL4 library file we have taken two steps: 1- Importing the external function from the library. 2- Using (calling) the function like any MQL4 function. Importing the external function: To be able to use the external function from your code you have to import it to your code. Importing the function takes three lines of code as you see above: #import "mylib.ex4" This is the first import line, we use the #import keyword followed by the library name, the line doesn't end with semi-colon. int MyExtFunction(int value,int value2); #import Then in the second line you declare the function very like the normal functions by writing the type of returned value followed by the function name then the parameters of the function and their types. Without this declaration your program will not know anything about the external function. You can import as many function as you want, in this case you write every function in a separate line. The declaration line must ends with semi-colon. To tell the compiler of MQL4 that you have finished your importing you have to write another line contains the #import keyword, but in this case without an external file. Note: You use only one #import line to end all the opened import lines, for example: #import "mylib.ex4" int MyExtFunction(int value,int value2); #import "mylib2.ex4" double MyExtFunction2(double value3); #import Calling the external function: If you have written right import block lines like the above description, you can call the external function very like calling any normal function in MQL4 program. In our program we called the MyExtFunction like this: int result = MyExtFunction(10,20); Alert ( result); We passed the numbers 10 and 20 to the function and assigned the returned value to the integer variable result. |
|
|
||||
|
||||
|
hi codersguru
would you help us.please see the link.
Gartley 222 Last edited by kamyar : 02-03-2006 at 10:14 PM. |
|
|
|||
|
|||
|
I moved your post to this thread but I am not sure about: may be this issue is not related ...
The other thread is here How to connect multiple EA’s in under 15 minutes! |
| Thread Tools | |
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Import custom DLL | The_N | Expert Advisors - Metatrader 4 | 1 | 05-30-2006 09:09 PM |
| #import questions | TheExponential | Questions | 5 | 12-09-2005 04:56 AM |