Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HEX values in VFP 1

Status
Not open for further replies.

webpager

Programmer
Mar 27, 2001
166
GB
I am trying to get the these values into this command line but I am unable to work out how to represent a HEX value.
I bet it is easy when you know how.

hwnd=(program derived screen handle)
msg1=&H400
msg2=50
msg3=122

B=SENDMESSAGE(HWND, Msg1, Msg2, Msg3)
 
Hello.

I hope that the following routines, written by Doug Hennig, would help you:

Decimal2Hex:
------------------------------
*==============================================================================
* Function: Decimal2Hex
* Purpose: Convert a decimal number to a hex string
* Author: Doug Hennig
* Copyright: (c) 2000 Stonefield Systems Group Inc.
* Last Revision: 11/02/2000
* Parameters: tnValue - the decimal value
* tnPlaces - the number of places needed (optional: if it
* isn't specified, 4 is used)
* Returns: the hex string
* Environment in: none
* Environment out: none
*==============================================================================

lparameters tnValue, ;
tnPlaces
local lnPlaces, ;
lcHex, ;
lnDecimal, ;
lnCurrDecimals, ;
lnPlaces, ;
lnI, ;
lnExponent, ;
lnTemp, ;
lcOut
lnPlaces = iif(pcount() = 1, 4, tnPlaces)
lcHex = ''
lnDecimal = tnValue
lnCurrDecimals = set('DECIMALS')
lnPlaces = iif(pcount() = 1, 4, tnPlaces)
set decimals to 17
for lnI = lnPlaces to 1 step -1
lnExponent = 256 ^ (lnI - 1)
lnTemp = int(lnDecimal/lnExponent)
lcHex = lcHex + chr(lnTemp)
lnDecimal = lnDecimal - lnTemp * lnExponent
next lnI
set decimals to lnCurrDecimals

* Reverse the order of the characters.

lcOut = ''
for lnI = 1 to lnPlaces
lcOut = lcOut + substr(lcHex, lnPlaces - lnI + 1, 1)
next lnI
return lcOut
-----------------------

and Hex2Decimal
-----------------------
*==============================================================================
* Function: Hex2Decimal
* Purpose: Converts a value in Intel format to a decimal value
* Author: Doug Hennig
* Copyright: (c) 2000 Stonefield Systems Group Inc.
* Last Revision: 11/02/2000
* Parameters: tcValue - the value to convert
* tlSigned - .T. if the value is signed
* Returns: the numeric value
* Environment in: none
* Environment out: none
*==============================================================================

lparameters tcValue, ;
tlSigned
local lnDecimal, ;
lnLen, ;
lnI, ;
lnMSB, ;
lnMax
lnDecimal = 0
lnLen = len(tcValue)
for lnI = 1 to lnLen
lnDecimal = lnDecimal + asc(substr(tcValue, lnI, 1)) * 256 ^ (lnI - 1)
next lnI
if tlSigned
lnMSB = (lnLen * 8) - 1
if bittest(lnDecimal, lnMSB)
lnMax = 2 ^ (lnMSB + 1)
lnDecimal = lnResult - lnMax
endif bittest(lnDecimal, lnMSB)
endif tlSigned
return lnDecimal
------------------

Hope this helps. Grigore Dolghin
Class Software
Bucharest, Romania
 
In VFP, you can use hex numbers directly by prefacing them with 0x (zero ex). So "msg1=&H400" (as you'd write it in Visual Basic) would be "msg1=0x400" in VFP.

Rick

Note to Grigore: It's consider at least "bad taste" to post Copyrighted code without the express consent of the author. In fact in the US it could even be grounds for a law suit. Although I want to make it clear that I'm NOT speaking for Doug Hennig in this case.
 
Hello, rgbean

This is code posted publicly by Doug Hennig itself. I don't violate any copyright. I only maintain the proper copyright and author mentions.

That's it. I hope we'll not have more such problems in the future.
Grigore Dolghin
Class Software
Bucharest, Romania
 
Not to mention anything that Dolghin had violated or not (the copyright laws) ...
It is my humble suggestion to Dolghin and other members ..

1. we can copy the thread when we download such codes and keep it at the head of the routines.
2. When we want to help others, we can just put the link in the public .. so that any one can reach that.
3. People who cannot follow the thread, can make personal communication and get things sorted out by the helping members.

However I appreciate Dolghin for having a straingt thinking for helping the community. It is only the safeguard I suggested and not for starting any controversy.
I also appreciate Rick for posting his comments and I understand he did neither start a controversy.

:) :) :)
ramani :)
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Hey guys, guys, guys!
I only asked a question and a few of you were good enough to reply and for this I am grateful but have a heart.
While you are carrying on your discussions on the whys and wherefores of what is right and what is wrong, I am receiving numerous E-mails telling me of a reply to my post. I get there and find the message isn`t for me.
Be gentle there are only so many hours in a day.
 
Hi all my friends,
For Grigore, You may not violate any of Doug's copyright, but you just violated his human rights by calling him '" itself" :) just kidding.
For WebPager, there is an option to remove this thread from your mailing notification, " Be gentle there " and use it.
But don't prevent us from responding to each other, being the one who started this thread, it doesn't mean that you own it.
Walid Magd
Engwam@Hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top