Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

integer(bool) or logical*4

davidgraham
Beginner
450 Views
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
------------------------------

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.

0 Kudos
2 Replies
netphilou31
New Contributor III
450 Views
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.
0 Kudos
Les_Neilson
Valued Contributor II
450 Views
It is to do with interfacing to Windows API stuff.
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
0 Kudos
Reply