Page 1 of 2

Hi and loword

Posted: Sat May 19, 2007 9:35 am
by Edwin Knoppert
I don't understand why a simple hi and loword aren't available at this time?

Afaik i made this request years ago..?

This is simpliest new feature one can bring to the compiler..

(I am aware of the workarounds)

Posted: Sat May 19, 2007 11:46 am
by Trond
It's called PeekW().

Posted: Sat May 19, 2007 3:07 pm
by Edwin Knoppert
You understand that the result might be the same but it isn't the same..

I mean i now have use pointer to variable + 2 bytes for lo or hi word.

Posted: Sat May 19, 2007 3:08 pm
by Edwin Knoppert
o btw, most of us won't know what bytes represent hi or low.
I have to look that up.

This is just another workaround for something obvious.

Posted: Sat May 19, 2007 3:42 pm
by Trond
What on earth would you need this for?
I mean i now have use pointer to variable + 2 bytes for lo or hi word.
Common!!
You don't need to use a separate pointer: PeekW(@Variable+2)

Posted: Sat May 19, 2007 4:27 pm
by Edwin Knoppert
Ever broken a wm_command's parameter in two?

Posted: Sat May 19, 2007 4:38 pm
by KarLKoX

Code: Select all

Macro LOWORD(Value)
  Value & $FFFF
EndMacro

Macro HIWORD(Value)
  (Value >> 16) & $FFFF
EndMacro 
:?:

Posted: Sat May 19, 2007 4:46 pm
by Edwin Knoppert
>(I am aware of the workarounds)

It seems better to argue than to implement this silly but helpful feature?
It's NOT that i want a macro in my app but a structural availability in the compiler.

Posted: Sat May 19, 2007 4:55 pm
by ts-soft
HiWord, LoWord and some other a implemented as macro in the win API, see the windows-headers, why not use Macros in PB :o
Native support for this only in languages, that doesn't support macro's

Posted: Sat May 19, 2007 4:57 pm
by Fred
We could add this in the Windows resident as Macro, it's not that useful except when dealing with crappy designed WinAPI.

Posted: Sat May 19, 2007 5:05 pm
by Edwin Knoppert
>We could add this in the Windows resident as Macro
Whatever, as long it becomes nativly available..

>, it's not that useful except when dealing with crappy designed WinAPI.
Certainly not my opinion, pb has it's flaws as well.

Posted: Sat May 19, 2007 5:07 pm
by thefool
Edwin Knoppert wrote: >, it's not that useful except when dealing with crappy designed WinAPI.
Certainly not my opinion, pb has it's flaws as well.
Come on, everybody knows that the windows api is a huge mess.. Even microsoft themself! Why would they else replace it with a new framework?

Posted: Fri Jan 18, 2008 8:53 pm
by superadnim
because managed frameworks provide you with an extra layer of security and ultimately portability.

Posted: Fri Jan 18, 2008 9:34 pm
by Trond
Megabump there!

I take back what I said, not because using PeekW() isn't easy, but because it's hard to remember which part is high and which is low.

I also like the Windows API, by the way, although it has a few flaws like this.

Posted: Sat Jan 19, 2008 2:29 am
by Rescator

Code: Select all

Macro LOWORD(a) : (a&$ffff) : EndMacro
Macro HIWORD(a) : ((a>>16)$ffff) : EndMacro
Macro MAKELONG(a,b) : ((a&$ffff)+b<<16) : EndMacro
I think these are correct?. (forgot a mask on HIWORD though, thanks KarLKoX)

These are from my BASS.pbi (for the BASS audio library)
It's needed for example for getting the version of the libary (it's returned as a long but the long is actually two words)

Yeah I know, a pointer to a structure is much better solution than LOWRD and HIWORD etc. but...
I do seem to run into these from time to time. (WinAPI and various C/C++ libs)