|
convert packed to alphaHi Stefan, First, to echo Jim, it would help if you did not send HTML and if you used something other than lowercase L as a field name. Second, the problem is the XLATE. In the examples where you get wrong data, your XLATE is converting the x'40' (blank) to x'00', so 3494402 would be translated to 3494002, and 5240211 would be 5200211. Third, although it doesn't affect anything, when you eval L = %len(hexstring), the result will always be 500. Try eval L = %len(%trimr(hexstring)) instead. The following (untested) should work: c eval num = *zero c eval L = %len(%trimr(hexstring)) c evalr char16 = %subst(hexstring:1:L) ....... c eval alphastring = %char(num) hth, Peter Dow Dow Software Services, Inc. 909 425-0194 voice 909 425-0196 fax ----- Original Message ----- From: Simmerlein, Stefan To: 'rpg400-l@midrange.com' Sent: Monday, July 09, 2001 1:47 AM Subject: convert packed to alpha Hi, i have some problems with this code. I've tested it with different numbers, (3617900 for example) and it works fine. In some cases i've got wrong results. For Example: hexstring = hex value of 3494402, 5240211 alphastring = 3494002, 5200211 Hexstring contains the hex value from a packed field (fieldxyz 9p 0). What's wrong ?????????? The code looks like this d universal_ds e ds extname(filexyz) ...... d universal s 500a ..... d hexstring s 500a (hexstring contains the hex value from a packed number) d alphastring s 500a inz (that's the result) d l s 3p 0 inz (length oh hexstring) d ds d num 30p 0 d char16 16 overlay(num) ....... c eval universal = universal_ds c eval hexstring = %subst(universal:1:5) (pos 1-5 = packed field 9p 0) ....... c eval l = %len(hexstring) c evalr char16 = %subst(hexstring:1:l) ....... c ' ':x'00' xlate char16 char16 c eval alphastring = %char(num) ....... _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.