Thursday, 14 September 2023

Peoplecode to get HEX values

 

Function hexVal(&iH As integer) Returns string
If &iH <= 9 Then
Return String(&iH);
Else
Return String(Char(Mod(&iH, 9) + 64));
End-If;
End-Function;


Function toHex(&iV As integer) Returns string
Local integer &iH = Mod(&iV, 16);
Local string &sResult = "";

If &iV - &iH = 0 Then
&sResult = hexVal(&iH);
Else
&sResult = toHex(Int((&iV - &iH) / 16)) | hexVal(&iH);
End-If;

Return &sResult;
End-Function;



&sHexValue = hexVal(Code("A"));

No comments:

Post a Comment