- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AllocConsole() and FreeConsole() APIs create and destroy a console window if there isn't any (as there's only one console per process allowed). Subsequent Fortran WRITEs should be able to operate on that console; I'm not sure, however, ifthey wouldin your setup (dll called from a non-Fortran app). If it doesn't, WriteConsole API should work.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AllocConsole etc. are native Windows APIs. CVF includes (almost) full translation of API functions & structures. However, the documentation (under "Platform SDK" branch) is still in C (as it's original Microsoft documentation); so you have to do some mental translation.
The modules are named KERNEL32, USER32, (the same as .lib mentioned in CVF docs); also, USE DFWINpulls in all the Win32 API modules. If in doubt, you canfind the searched function/structin appropriate module(or do a "Find in Files" in ...Visual StudioDF98Include) and see the Fortran INTERFACE/TYPE to it. For example, having seen the interface to above-mentioned WriteConsole (it's a tricky one due to lot of pointers (LPxxxx types)), a correct call to outputan integeron the console would be:
USE KERNEL32 CHARACTER(10):: sOut
INTEGER:: i, nOut
i = 42
WRITE(sOut, *) i !You have to write to a string first
result = WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), &
LOC(sOut), LEN_TRIM(sOut), LOC(nOut), 0)
So, you have to USE KERNEL32 or USE DFWIN to be able tobuild AllocConsole etc.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK Yugoslav! I forgot the USE statement!:smileyvery-happy:
The correct code is:
......
USE kernel32
logical s
s = AllocConsole()
print *, "Hallo world!"
pause
s = FreeConsole()
....
![](/skins/images/D2683F18326913BBA0436CB7114DD569/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page