- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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 kopiert
2 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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

Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite