- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have never used integer(bool) and not sure of its usage.
Are these two statements the same?
---------------------------------
integer(bool) bRet
bRet=PeekMessage(msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_NOREMOVE)
if (bRet==0) then
! no messages
else
! valid message
end if
----------------------------
logical*4 lRet
lRet=PeekMessage(msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_NOREMOVE)
if (lRet) then
! valid message
else
! no messages
end if
------------------------------
Are these two statements the same?
---------------------------------
integer(bool) bRet
bRet=PeekMessage(msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_NOREMOVE)
if (bRet==0) then
! no messages
else
! valid message
end if
----------------------------
logical*4 lRet
lRet=PeekMessage(msg,hWndMain,WM_KEYDOWN,WM_KEYDOWN,PM_NOREMOVE)
if (lRet) then
! valid message
else
! no messages
end if
------------------------------
The documentation for peekmessage is:
Return Value
Type: BOOL
If a message is available, the return value is nonzero.
If no messages are available, the return value is zero.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi David,
I think that the integer(BOOL) statement declares an integer variable that can receive any integer value as the logical(4) statement declares a logical variable that can have only two possible values (.true. and .false.).
Anyway if you are not sure of the right syntax, the best way is to look at the user32.f90 module file which is available in the INCLUDE directory of the compiler. In the case of the PeekMessage the interface definition is :
[fortran]FUNCTION PeekMessage( & lpMsg, & hWnd, & wMsgFilterMin, & wMsgFilterMax, & wRemoveMsg) use ifwinty integer(BOOL) :: PeekMessage ! BOOL !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'PeekMessageA' :: PeekMessage !DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: lpMsg TYPE (T_MSG) lpMsg ! LPMSG lpMsg integer(HANDLE) hWnd ! HWND hWnd integer(UINT) wMsgFilterMin ! UINT wMsgFilterMin integer(UINT) wMsgFilterMax ! UINT wMsgFilterMax integer(UINT) wRemoveMsg ! UINT wRemoveMsg END FUNCTION END INTERFACE[/fortran]
Best regards,
Phil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is to do with interfacing to Windows API stuff.
Searching the IVF help for integer(bool) shows the following :
So if a Windows API function returns a BOOL then assign it to an INTEGER(BOOL) and so on.
Les
Searching the IVF help for integer(bool) shows the following :
Module IFWINTY defines a set of constants ... that correspond to many of the type definitions provided in the WINDOWS.H header file.
Windows Data Type Equivalent Fortran Data Type
BOOL, BOOLEAN INTEGER(BOOL)
Note that the Windows BOOL type is not equivalent to Fortran LOGICAL and should not be used with Fortran LOGICAL operators and literal constants. Use the constants TRUE and FALSE, rather than the Fortran literals .TRUE. and .FALSE., and do not test BOOL values using LOGICAL expressions.
So if a Windows API function returns a BOOL then assign it to an INTEGER(BOOL) and so on.
Les

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