- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm developing a windows application that uses fortran DLL. I'm asking your help in two things:
1- I want the fortran to write on a console during the execution of the fortran code. I used the AllocConsole, the console appears when running the program but it's always empty.
2- I want the same message printed on a console window to be printed at the same time on a Listbox in the windows application. For this one i will be thankful if you can provide me with steps to do it. I don't even know if it's possible.
I attached the program so you can check it.
Thanks in advance,
Li
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to say:
!DEC$ ATTRIBUTES STDCALL :: Fort1
You ignored the compiler's warning message telling you the syntax was wrong.
I clicked the button multiple times and it worked fine (once I added STDCALL).
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see a sample program attached.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It should appear now.
Sorry about that !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, a few things.
First, you need to add STDCALL to the ATTRIBUTES line for the subroutine, or else you'll corrupt the stack.
Second, the reason you don't see the console window output is because the VB debugger captures and hides it. If you "Start without debugging" you will see the output. There's nothing we can do about this.
Third, there is no way to have the output automatically sent to both the console and a list box. You certainly can add code to the Fortran routine to do both, creating a MessageBox or some other form control to which you write output, but you can't use Fortran I/O directly to do these writes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Steve,
May i ask two more questions please.
1) To add the STDCALL i simply added the following line to the fortran code:
!DEC$ ATTRIBUTES:: STDCALL
i added nothing to the VB Form. Is there anything else that i need to add ?
2) If i double click the windowsapplication.exe i can now see the output on the console when i click the button, however
if i click the button 2 or three times i get the following message (see attached) how can i solve this ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need to say:
!DEC$ ATTRIBUTES STDCALL :: Fort1
You ignored the compiler's warning message telling you the syntax was wrong.
I clicked the button multiple times and it worked fine (once I added STDCALL).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot Steve,
You helped me a lot.
Now it's working fine, the only problem left is if i added
b=freeconsole() after the loop
and i click several times the button on windowsapplication.exe i get the same message i attached in my previous comment, even
if i added the STDCALL. I don't know if this could be solved. But thanks a lot for your help !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Don't do the freeconsole - it will just cause problems.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page