Here are some simple steps to create a DLL to use with Meta Trader 4 or VB6.
NOTE: I assume that you have basic programming knowledge.
- Download Free Basic Here
- Install Free Basic in its default Location. You can read here about FreeBasic.
- Free Basic is free programming language to write programs like in MS VB.
- After installing FreeBasic, now write your dll code. For example open your favorite text editor and type the following sample code:
- All your functions should be between the commands [extern "windows-ms"] and [end extern].
- Now save the file as “mathlib.bas”. DOWNLOAD HERE sample file and DLL. As we have math functions so we are giving mathlib name, you can give it any other name. If you did not set your path variable to free basic then save file in folder: c:freebasicfreebasicmathlib.bas
- Now open DOS command prompt and change directory to:
- Now type the following command to compile your file into dll.
- This will create a mathlib.dll file. Now you can use this dll with any windows application like Meta Trader 4 or VB6.
- NOTE: If you have set your path variable to freebasic, then you can invoke “fbc” command from any directory.
extern "windows-ms"
function Add( byval x as integer, byval y as integer ) as integer export
function = x + y
end function
function subtraction(byval x as integer, byval y as integer) as integer export
function = x - y
end function
function divide(byval x as integer, byval y as integer) as double export
function = x / y
end function
function multi(byval x as integer, byval y as integer) as integer export
function = x * y
end function
function square(byval x as integer) as integer export
function = x * x
end function
function cube(byval x as integer) as integer export
function = x * x * x
end function
end extern
c:freebasicfreebasic
c:freebasicfreebasic>fbc -dll mathlib.bas