View previous topic :: View next topic |
Author |
Message |
hillbilly78
Joined: 01 Nov 2006 Posts: 3
|
Posted: Thu Nov 02, 2006 1:21 am Post subject: Creating a dll in Plato IDE and using with Visual Basic |
|
|
Hi everyone,
I am trying to create a Fortran dll using the Plato IDE that can be used in my Visual Basic programs. I would like to know the procedures required to
1.) Make a dll using Plato (including settings required, etc)
2.) Implement the dll in Visual Basic (including declarations and references, etc)
Also has any one got any websites or information they could share regarding how data is passed between the dll and Visual Basic (e.g. what data types can be used) and if there are any pitfalls, etc.
Thanks in advance.
Stuart |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Nov 03, 2006 12:42 am Post subject: Creating a dll in Plato IDE and using with Visual Basic |
|
|
Stuart
The place to start is "Calling an FTN95 DLL from Visual Basic" in the FTN95 help file.
You need to create a "Fortran Application Extension" project in Plato3.
You can pass simple scalars and arrays (by reference) but avoid passing strings.
Try to avoid using global data in the DLL otherwise things get more difficult (you will need to use LoadLibrary and possibly your own "DLLMain")
Use F_STDCALL in your subprogram definition. |
|
Back to top |
|
|
hillbilly78
Joined: 01 Nov 2006 Posts: 3
|
Posted: Fri Nov 03, 2006 3:18 am Post subject: Creating a dll in Plato IDE and using with Visual Basic |
|
|
I have created a Fortran Application Extension project with just one function in which is:
F_STDCALL INTEGER*4 FUNCTION MyFunc(X)
INTEGER*4 X
MyFunc=X
END
I have created the DLL called "FortranTestDLL.dll" (ticking the export all option under Project->Properties->Linker Options) and then placed it in my Visual Basic project directory. In my Visual Basic Project I declared the function in the DLL using:
Public Declare Function MyFunc Lib "FortranTestDLL.dll" (ByRef X As Long) As Long
When the VB project is executed an error occurs which is
"Run-time error '453':
Can't find DLL entry point MyFunc in FortranTestDLL.dll"
Is there something else I am missing?
Thanks,
Stuart |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Nov 03, 2006 5:01 am Post subject: Creating a dll in Plato IDE and using with Visual Basic |
|
|
Fortran exports are uppercase MYFUNC. |
|
Back to top |
|
|
hillbilly78
Joined: 01 Nov 2006 Posts: 3
|
Posted: Fri Nov 03, 2006 6:12 am Post subject: Creating a dll in Plato IDE and using with Visual Basic |
|
|
That works fine now, thanks.
Stuart |
|
Back to top |
|
|
|