1. PRASHANT NIRGUN
  2. PowerBuilder
  3. Monday, 23 March 2020 11:52 AM UTC

I want to convert hex values to String Is there any way out ? At present I am making a database call but this will not work in future as we are planning to moving from on premises to cloud database. I don't want this round trip. Any one has article please share

<pre>

//input 35394330315931324131

SELECT unhex(:ls_code) INTO :ls_unhex from DUAL;

// return 59C01Y12A1

 

SELECT hex('59C01Y12A1') from DUAL;

//return 35394330315931324131
</pre>

 

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 23 March 2020 20:38 PM UTC
  2. PowerBuilder
  3. # 1

Hi Prashant;

  My STD framework has two global functions ... "fn_long2hex" and "fn_hex2long". You are most welcome to download the open source framework and then copy and adopt any part of the framework (or in this case global functions) for your own application use.

HTH

Regards ... Chris

Comment
  1. Roland Smith
  2. Monday, 23 March 2020 23:42 PM UTC
Don't you support only the most current version of PB? Since he is using 12.5, he won't be able to use it.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 24 March 2020 00:08 AM UTC
Older versions of the frameworks are in their respective "Archive" sub-folders. I have even older PB versions offline as well. ;-)
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 23 March 2020 17:36 PM UTC
  2. PowerBuilder
  3. # 2

Here is a function that converts a number to Hex. You'll notice that it makes calls to itself (recursion). The argument ai_digit is the number of hex digits you want which allows it to have zeros in the front as needed.

 

public function string hex (unsignedlong aul_number, integer ai_digit);Char lc_ret
ULong lul_temp0, lul_temp1

If ai_digit > 0 Then
lul_temp0 = Abs(aul_number / (16 ^ (ai_digit - 1)))
lul_temp1 = lul_temp0 * (16 ^ (ai_digit - 1))
If lul_temp0 > 9 Then
lc_ret = Char(lul_temp0 + 55)
Else
lc_ret = Char(lul_temp0 + 48)
End If
Return lc_ret + Hex(aul_number - lul_temp1, ai_digit - 1)
End If

Return ""

end function

Comment
There are no comments made yet.
PRASHANT NIRGUN Accepted Answer Pending Moderation
  1. Monday, 23 March 2020 16:53 PM UTC
  2. PowerBuilder
  3. # 3

so sorry I have not mentioned I am using PB 12.5.2 

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 23 March 2020 14:36 PM UTC
  2. PowerBuilder
  3. # 4

If you have PB2019, take a look at the CoderObject.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.