Data Access Worldwide Knowledge Base
Article ID 2196 Article Title EXAMPLE: Functions to convert to and from hexadecimal Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2196 KBase Category VDF11 Date Created 12/02/2005 Last Edit Date 12/09/2005
Article Text
QUESTION:
I need to convert a string to a hexadecimal value. How do I do that?
ANSWER:
It is quite easy to write such a function in DataFlex, but it is easier to use the function StrToHex from the enclosed cHexLib class. You can use it as follow:
Use Windows.Pkg
Use cHexLib.Pkg
Procedure DoTest Desktop
Handle hoHexLib
Boolean bIsHex
String sValue
Integer iValue
Get Create U_cHexLib To hoHexLib
If (hoHexLib) Begin
Get IsHex Of hoHexLib "FFFFFA" To bIsHex
Showln "bIsHex: " bIsHex
Get IsHex Of hoHexLib "FGFFFA" To bIsHex // This is not correct HEX
Showln "bIsHex: " bIsHex
Get StrToHex Of hoHexLib "DataFlex is a GREAT product!" To sValue
Showln "sValue: " sValue
Get HexToStr Of hoHexLib sValue To sValue
Showln "sValue: " sValue
Get DecToHex Of hoHexLib 129 To sValue
Showln "sValue: " sValue
Get HexToDec Of hoHexLib "A0" To iValue
Showln "iValue: " iValue
Send Destroy Of hoHexLib
End
End_Procedure
Send DoTest
Send Info_Box "Ready"
Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu
Web Links Related to this Article
File cHexLib.Pkg
URL=http://www.dataaccess.com/KBasePublic/Files/2196.cHexLib.Pkg
Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.
The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.