- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
iret below is defind as a 4 byte integer, and Loword(), a win32 macro, returns a 2 byte integer. Should the assignement be stated as,
iret = Loword(wParam)
or,
iret = Int4(Loword(wParam))
Thank you for a reply.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Either one is ok. Fortran defines implicit conversion between numeric types and kinds. But you'll get sign-extension which you may not want. Consuder using zext instead of int4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
Also, I noticedin the documentation for INT (Chap. 9 Intrinsic Procedures) that the table with Specific names is missing the names for the 1st twoitems. Can you tell me what these Specific names are?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There aren't specific names for those. Specific names are a relic of Fortran 66 and should generally be avoided.
Use generics, with the optional KIND= specifier if needed. For example:
INT (X,1)
Use generics, with the optional KIND= specifier if needed. For example:
INT (X,1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have to be very careful with LOWORD/HIWORD. I'm not sure what's the exact prototype of VF-supplied ones, but I tend to use the following statement functions instead, as I've been badly beaten with it:
The usage depends on the context, and what the API documentation says that the result should be casted into -- WORD means "unsigned", short means "unsigned".
The difference comes to light when the e.g. bit 15 of the loword/hiword is set. (E.g. Hex 0000FFFF - The "unsigned" versions will return 65535, and signed -1).
For example, mouse messages (WM_MOUSEMOVE) can contain negative coordinates when the mouse is captured; in this case, signed versions are called for. If you, OTOH, use the signed version for WM_COMMAND, your control IDs greater than 32767 will not work.
I (hope I) have the complete and correct list of usages per window message (that's the most common place where *LOWORD is used).
INTEGER XLOWORD, XHIWORD, SLOWORD, SHIWORD
XLOWORD(i) = IAND(i, Z'FFFF') !Unsigned versions
XHIWORD(i) = ISHL(i, -16)
SLOWORD(i) = INT(INT(IAND(i, Z'FFFF'),2)) !Signed versions
SHIWORD(i) = INT(INT(ISHL(i, -16),2))
The usage depends on the context, and what the API documentation says that the result should be casted into -- WORD means "unsigned", short means "unsigned".
The difference comes to light when the e.g. bit 15 of the loword/hiword is set. (E.g. Hex 0000FFFF - The "unsigned" versions will return 65535, and signed -1).
For example, mouse messages (WM_MOUSEMOVE) can contain negative coordinates when the mouse is captured; in this case, signed versions are called for. If you, OTOH, use the signed version for WM_COMMAND, your control IDs greater than 32767 will not work.
I (hope I) have the complete and correct list of usages per window message (that's the most common place where *LOWORD is used).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Steve, Jugoslav. Info was very helpful. Jugoslav, thanks for the detailed info on using LOWORD/HIWORD: something I had not thought about before now.

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