Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Hex to String Post Reply Post New Topic
Author Message
kkemp
Newbie
Newbie


Joined: 05 Nov 2008
Online Status: Offline
Posts: 3
Quote kkemp Replybullet Topic: Hex to String
     Posted: 05 Nov 2008 at 6:59am
I am needing to convert the values in a database column which are hexadecimal into a string on a Crystal Report.
 
The data is in an Oracle database, the column is defined as a VARCHAR2.
 
Looking for ideas on how to do this to show the data in Crystal Reports. I am using version 10.
 
Thanks!
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 05 Nov 2008 at 7:25am
IP IP Logged
kkemp
Newbie
Newbie


Joined: 05 Nov 2008
Online Status: Offline
Posts: 3
Quote kkemp Replybullet Posted: 05 Nov 2008 at 9:12am
the link is for a pay site. didn't really want to have to fork out any $$
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Nov 2008 at 6:32am

Okie............

 
This formula converts a Hex string parameter (RefNumber) to a decimal value:

// Hex To Dec
numberVar x := len({?RefNumber});
numberVar base16 := 1;
numberVar value := 0;
numberVar decval := 0;
stringVar s;

while x > 0 do
(
    s := mid({?RefNumber},x,1);
    if s = "F" then
        decval := 15
    else if s = "E" then
        decval := 14
    else if s = "D" then
        decval := 13
    else if s = "C" then
        decval := 12
    else if s = "B" then
        decval := 11
    else if s = "A" then
        decval := 10
    else
        decval := cdbl(s);

    value := value + (base16 * decval);
    base16 := base16 * 16;
    x := x - 1;
);

value;
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum