- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello,
i am trying to integrate fortran exe with an atl dll (c++).
what i want to do is from the fortran app to call a function of the dll, pass string into it, modify it (in c++) and then return it to fortran.
i dont want to return it as a return value of the function but pass it as a pointer, so that it will be imediately available to the fortran app after the dll call.
i have no experience with fortran, read many posts here, tried things out and with the interface wizard and managed to pass the string where in the dll the argument is a BSTR. However, if i change the BSTR, after return of the function the original fortran string is not changed.
i have access to the dll (c++) and can use any interface (BSTR was just an experiment. i can use char * if necessary or whatever.
in your opinion, what is the best types in both fortran and c++ that i can use to achieve this? i know for sure but it has to be passed by ref somehow so that i can change the string within the c++ dll. But how do i make it to be available in fortran after the return of the c++ function in the dll?
thank you in advance for your help.
p.s. my experience in fortran is next to nothing so please be as descriptive as you can
Regards,
JC
i am trying to integrate fortran exe with an atl dll (c++).
what i want to do is from the fortran app to call a function of the dll, pass string into it, modify it (in c++) and then return it to fortran.
i dont want to return it as a return value of the function but pass it as a pointer, so that it will be imediately available to the fortran app after the dll call.
i have no experience with fortran, read many posts here, tried things out and with the interface wizard and managed to pass the string where in the dll the argument is a BSTR. However, if i change the BSTR, after return of the function the original fortran string is not changed.
i have access to the dll (c++) and can use any interface (BSTR was just an experiment. i can use char * if necessary or whatever.
in your opinion, what is the best types in both fortran and c++ that i can use to achieve this? i know for sure but it has to be passed by ref somehow so that i can change the string within the c++ dll. But how do i make it to be available in fortran after the return of the c++ function in the dll?
thank you in advance for your help.
p.s. my experience in fortran is next to nothing so please be as descriptive as you can
Regards,
JC
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hello again,
sorry to disturb again but i have been trying today again to solve the problem but i didnt get anywhere...
can anyone please tell me if what i try to do is possible? or am i wasting my time with the BSTRs and gotta find another way of doing it?
thank you in advance
regards
jc
sorry to disturb again but i have been trying today again to solve the problem but i didnt get anywhere...
can anyone please tell me if what i try to do is possible? or am i wasting my time with the BSTRs and gotta find another way of doing it?
thank you in advance
regards
jc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
BSTRs are really more for VB. Yes, what you want to do is possible. Fortran will pass a CHARACTER variable as an address and a length. The address can be looked at as a char* in C, but Fortran won't know to look for a trailing NUL unless you code it yourself with an INDEX call after thr return.
See the mixed-language programming chapter of the User Manual for more details.
See the mixed-language programming chapter of the User Manual for more details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello and thank you for your reply,
So far i can pass the fortran string to BSTR of the atl object. The opposite seems to be the problem, ie alter the BSTR in the ATL object in a way that changes will be imediately available to the fortran program.
Also, i have managed to do it using straight win32 api and works ok. I created the interface (not using the wizard) and put my functions in the a static C .lib that calls varius visual objects.
The reason i was insisting to an ATL / OLE / COM technology is that you can do visual stuff at a higher level instead of coding message loops...
The mixed language manual stuff, when it comes to BSTR are more 'call fortran from vb' oriented while i try to do the opposite...
In any case, if you have / find any example of this please let me know.
Regards
JC
So far i can pass the fortran string to BSTR of the atl object. The opposite seems to be the problem, ie alter the BSTR in the ATL object in a way that changes will be imediately available to the fortran program.
Also, i have managed to do it using straight win32 api and works ok. I created the interface (not using the wizard) and put my functions in the a static C .lib that calls varius visual objects.
The reason i was insisting to an ATL / OLE / COM technology is that you can do visual stuff at a higher level instead of coding message loops...
The mixed language manual stuff, when it comes to BSTR are more 'call fortran from vb' oriented while i try to do the opposite...
In any case, if you have / find any example of this please let me know.
Regards
JC
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page