Post by Walt Decker on Dec 14, 2020 11:29:10 GMT -5
I do not know if this is the proper place or if these functions a located elsewhere in LB but here they are:
OPEN "NUMBERMANDLL" FOR DLL AS #HANDL
"FN_SetLong", Loword AS SHORT, _ '<--- Low word
Hiword AS SHORT, _ '<--- High word
NewVal AS LONG '<--- Returns a LONG
Why would anyone want to do that. Windows does it. If you are familiar with callback functions
under WM_COMMAND wParam has two parts. The low word is a control ID and the high word is the
action part, for example BN_CLICKED. Under WM_L/M/RBUTTONDOWN the low word is the X coordinante and the Y coordinate is the high word of wParam.
If you write a non-recursive flood-fill routine you can use it to store the X,Y coordinate of a pixel in an array thereby reducing the number of elements in the array and equating each element to a pixel position.
"FN_GetLowWord", _ '<--- Gets the low word of a long
ValueIn AS SHORT, _ '<--- A word value
NewValue AS LONG '<--- LB does not have an integer type, but
'the return value will be an integer
"FN_GetHiWord", _ '<--- Gets the high word of a long
ValIn AS SHORT, _
NewValue AS LONG
"FN_SetWord", _ '<--- Sets the low and high bytes of an
'integer
LoByte AS USHORT, _ <--- LoByte/HiByte must be in the range
_ '0 to 255. Unexptected result will occur
_ 'if not in that range
HiByte AS USHORT, _
NewValu AS LONG 'Returns a USHORT(unsigned integer)
"FN_GetLowByte", _
ValIn AS USHORT, _ '<--- LB does not have a byte(CHAR)
ByteVal AS LONG '<--- Returns the low byte of an integer
"FN_GetHiByte", _
ValIn AS USHORT, _
ByteVal AS LONG '<--- Returns the high byte of an integer
"FN_SetBitValue", _ '<--- Sets or clears a bit in a 32-bit value
InVal AS LONG, _ '<--- Value in which to set the bit
BitPos AS USHORT, _ '<--- Bit position, must be in range of
_ '0(zero) to 31
BitVal AS USHORT, _ '1(one) sets the bit; 0(zero) clears it
RetVal AS LONG '<--- New value of InVal
"FN_GetBitVal", _
ValIn AS LONG, _ '<--- Value to query
BitPos AS USHORT, _ '<--- Bit position to check; must be in
_ 'range of 0(zero) to 31
RetVal AS LONG '<--- Value of bit; 0(zero) = unset, 1(one) = set
' -1 if bit value is out of range
"FN_SetLongBytes", _ '<--- Sets all the bytes in a 32 bit value
ValIn AS LONG, _ '<--- 32 bit value; usually 0(zero)
Byt0 AS USHORT, _ '<--- Low byte; 0(zero) to 255
Byt1 AS USHORT, _ '<--- High byte of low word, 0 - 255
Byt2 AS USHORT, _ '<--- Low byte of high word, 0 - 255
Byt3 AS USHORT, _ '<--- High byte of high word, 0 - 255
NewVal AS LONG '<--- Return value. If input "bytes" are not
' in the 0(zero) to 255 range unexpected
' results will occurr
Why would anyone do this. Well, given the date "December 7, 1942" one could
store the date in one long, e. g. 12 7 19 42.
"FN_SetRGB", _ '<--- Creates an RGB value
Red AS ULONG, _ '<--- Red, Green, Blue value range is 0(zero) - 255
Green AS USHORT, _
Blue AS USHORT, _
RgbVal AS ULONG '<--- RGB value. If Red, Green, Blue is not
' within range unexpected results will occurr
"FN_SetBGR", _ '<--- Creates a blue, green, red value
Red AS USHORT, _ '<--- Red, Green, Blue range = 0(zero) to 255
Green AS USHORT, _
Blue AS USHORT, _
BgrVal AS ULONG '<--- Returns a BGR value. If Red, Green, Blue
' are out of bounds unexpected results will occurr
"FN_RGBtoBGR", _ '<--- Translates Red, Green, Blue to Blue, Green, Red
RgbIn AS ULONG, _ '<--- Red, Green, Blue value
BgrVal AS ULONG '<--- BGR value
"FN_BGRtoRGB", _ '<--- Translates Blue, Green, Red to Red, Green, Blue
BgrIn AS ULONG, _ '<--- Blue-Green-Red value
RgbVal AS ULONG '<--- RgbValue
There are four addition functions in the dll, but they will not work in LB because it does not allow by reference numeric arguments in a dll call.
"FN_SetLong", Loword AS SHORT, _ '<--- Low word
Hiword AS SHORT, _ '<--- High word
NewVal AS LONG '<--- Returns a LONG
Why would anyone want to do that. Windows does it. If you are familiar with callback functions
under WM_COMMAND wParam has two parts. The low word is a control ID and the high word is the
action part, for example BN_CLICKED. Under WM_L/M/RBUTTONDOWN the low word is the X coordinante and the Y coordinate is the high word of wParam.
If you write a non-recursive flood-fill routine you can use it to store the X,Y coordinate of a pixel in an array thereby reducing the number of elements in the array and equating each element to a pixel position.
"FN_GetLowWord", _ '<--- Gets the low word of a long
ValueIn AS SHORT, _ '<--- A word value
NewValue AS LONG '<--- LB does not have an integer type, but
'the return value will be an integer
"FN_GetHiWord", _ '<--- Gets the high word of a long
ValIn AS SHORT, _
NewValue AS LONG
"FN_SetWord", _ '<--- Sets the low and high bytes of an
'integer
LoByte AS USHORT, _ <--- LoByte/HiByte must be in the range
_ '0 to 255. Unexptected result will occur
_ 'if not in that range
HiByte AS USHORT, _
NewValu AS LONG 'Returns a USHORT(unsigned integer)
"FN_GetLowByte", _
ValIn AS USHORT, _ '<--- LB does not have a byte(CHAR)
ByteVal AS LONG '<--- Returns the low byte of an integer
"FN_GetHiByte", _
ValIn AS USHORT, _
ByteVal AS LONG '<--- Returns the high byte of an integer
"FN_SetBitValue", _ '<--- Sets or clears a bit in a 32-bit value
InVal AS LONG, _ '<--- Value in which to set the bit
BitPos AS USHORT, _ '<--- Bit position, must be in range of
_ '0(zero) to 31
BitVal AS USHORT, _ '1(one) sets the bit; 0(zero) clears it
RetVal AS LONG '<--- New value of InVal
"FN_GetBitVal", _
ValIn AS LONG, _ '<--- Value to query
BitPos AS USHORT, _ '<--- Bit position to check; must be in
_ 'range of 0(zero) to 31
RetVal AS LONG '<--- Value of bit; 0(zero) = unset, 1(one) = set
' -1 if bit value is out of range
"FN_SetLongBytes", _ '<--- Sets all the bytes in a 32 bit value
ValIn AS LONG, _ '<--- 32 bit value; usually 0(zero)
Byt0 AS USHORT, _ '<--- Low byte; 0(zero) to 255
Byt1 AS USHORT, _ '<--- High byte of low word, 0 - 255
Byt2 AS USHORT, _ '<--- Low byte of high word, 0 - 255
Byt3 AS USHORT, _ '<--- High byte of high word, 0 - 255
NewVal AS LONG '<--- Return value. If input "bytes" are not
' in the 0(zero) to 255 range unexpected
' results will occurr
Why would anyone do this. Well, given the date "December 7, 1942" one could
store the date in one long, e. g. 12 7 19 42.
"FN_SetRGB", _ '<--- Creates an RGB value
Red AS ULONG, _ '<--- Red, Green, Blue value range is 0(zero) - 255
Green AS USHORT, _
Blue AS USHORT, _
RgbVal AS ULONG '<--- RGB value. If Red, Green, Blue is not
' within range unexpected results will occurr
"FN_SetBGR", _ '<--- Creates a blue, green, red value
Red AS USHORT, _ '<--- Red, Green, Blue range = 0(zero) to 255
Green AS USHORT, _
Blue AS USHORT, _
BgrVal AS ULONG '<--- Returns a BGR value. If Red, Green, Blue
' are out of bounds unexpected results will occurr
"FN_RGBtoBGR", _ '<--- Translates Red, Green, Blue to Blue, Green, Red
RgbIn AS ULONG, _ '<--- Red, Green, Blue value
BgrVal AS ULONG '<--- BGR value
"FN_BGRtoRGB", _ '<--- Translates Blue, Green, Red to Red, Green, Blue
BgrIn AS ULONG, _ '<--- Blue-Green-Red value
RgbVal AS ULONG '<--- RgbValue
There are four addition functions in the dll, but they will not work in LB because it does not allow by reference numeric arguments in a dll call.
NUMBERS.ZIP (4.98 KB)