× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I would expect 12345F if the rick had specified 6 nibbles, but 12345 if only 5 nibbles were requested. Now that I think about it more, 'X' works like MOVEL, so should strip even the implied decimal, but I don't think it changes negative numbers to letters, or it could. That will have to be tested.

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx

-----rpg400-l-bounces@xxxxxxxxxxxx wrote: -----
To: <rpg400-l@xxxxxxxxxxxx>
From: "Lim Hock-Chai"
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
Date: 02/24/2011 05:23PM
Subject: Re: cvthc not converting all values

Ah, so the source string actually contains the actual packed value.  In that case I would expect cvthc to return 12345F (not sure though).  

But regardless, if you don't want decimal point, you can simply use the 'X' edit code (I think X also eliminate sign, not sure).

%editc(myPackDec :'X');

"Mark Murphy/STAR BASE Consulting Inc." <mmurphy@xxxxxxxxxxxxxxx> wrote in message news:<mailman.30983.1298584908.2702.rpg400-l@xxxxxxxxxxxx>...
I would expect it to.  cvthc takes the hex representation of a string and pulls each nibble out into it's character representation so it takes the first 5 nibbles of x'12345f' and converts it to a character string of '12345'.  Why not use %char or %editc?  I suspect that Rick doesn't want to see the implied decimal point.  I have some data export functions where the user doesn't want the implied decimal points, in fact it is a standard Automatic Clearing House format.  In my case I know there are two decimal positions so I can just multiply by 100, but what if I had an application where I didn't know the decimal positions?  I know of one ERP where the implied decimal position is stored in the record in a separate field just so they can handle currencies that do not use "cents".

Mark Murphy
STAR BASE Consulting, Inc.
mmurphy@xxxxxxxxxxxxxxx

-----rpg400-l-bounces@xxxxxxxxxxxx wrote: -----
To: rpg400-l@xxxxxxxxxxxx
From: "hockchai Lim"
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
Date: 02/24/2011 03:50PM
Subject: Re: cvthc not converting all values

using cvthc?  and you get the expected result?

Also, you can always hard code a max length and decimal position value on
%dec that will cover all possible different combination of len and decpos.
Such as
myDec = %dec(myString :64 :30).   Now if your data actually exceed this big
number, then we are talking about some serious money here.  In that case,
I'll just be quite.... ;).



<Rick.Chevalier@xxxxxxxxxxxxxxx> wrote in message
news:mailman.30961.1298579704.2702.rpg400-l@xxxxxxxxxxxx...
Sorry, I wasn't clear.  It is a character representation of a packed field.
The source value is a character field that looks like x'12345F'.  The length
could vary as well as the decimal places.  I am 'unpacking' it into a
character field that will have '12345'.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of hockchai Lim
Sent: Thursday, February 24, 2011 2:11 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: cvthc not converting all values

When you say "I am unpacking a packed field into a character string.", is
that means that you have a packed decimal field and you call the cvthc to
change that packed field into character string?  if so, why not just use
%char or %editc?

<Rick.Chevalier@xxxxxxxxxxxxxxx> wrote in message
news:mailman.30934.1298574735.2702.rpg400-l@xxxxxxxxxxxx...
No, it's the right one.  %Dec won't work because I can't use variables for
the length and decimals.  I am unpacking a packed field into a character
string.  The definition of the field is passed with the value.

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of hockchai Lim
Sent: Thursday, February 24, 2011 10:18 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: cvthc not converting all values

could you have mis-understood what this api does.  cvthc is intended to
convert a char string into a hex representation of the char string.  So if
you have a char string containing value of 'TEST, it produces the result of
'E3C5E2E3'.

Also, your prototype for cvthc is not correct.  May be scott's article would
help understanding more about this api:
http://systeminetwork.com/article/convert-data-and-hexidecimal.

For what you want to do (if I understand you correctly), all you need is
%char or %editc.



<Rick.Chevalier@xxxxxxxxxxxxxxx> wrote in message
news:mailman.30867.1298562517.2702.rpg400-l@xxxxxxxxxxxx...
I have been reading the archives and looking at the MI Reference manual but
I just can't figure out what I'm doing wrong.  I am trying to convert a
5-digit packed value into a character value.  cvthc is only converting the
first byte.  My test value is 12345F and my results are 12, only the first
byte.  The manual shows an example where it is converting a 9-byte value to
character with one call.  I have verified that the length I am passing is 5.
I also tried 6.  Any thoughts on what I'm doing wrong?

This is the prototype:
     d HexToChar       pr                  ExtProc('cvthc')
     d  Receiver                       *   Value
     d  Source                         *   Value
     d  Length                       10u 0

This is the function call:
HexToChar(%Addr(ReplaceString)
         :NameValuePairs.dsNameValue(Ctr).Value
         :NameValuePairs.dsNameValue(Ctr).ValueByteLength);

Definitions:
     d ReplaceString   s             64a


     d dsNamesValues...
     d                 ds                  Qualified Based(Dummy)
     d  NumberOfValues...
     d                                5u 0
     d  dsNameValue                        LikeDS(dsNameValue_t) Dim(1000)


     d dsNameValue_t   ds                  Qualified Based(Dummy)
     d  Name                         32a
     d  DataType                      3u 0
     d  NumericLength                 3u 0
     d  Decimals                      3u 0
     d  DTZFormat                     3u 0
     d  DTSeparator                   1a
     d  ValueByteLength...
     d                               10u 0
     d  MaxValueByteLength...
     d                               10u 0
     d  Value                          *

Rick Chevalier
IT Software Solutions - Loan Servicing
GM Financial/AmeriCredit
817-525-7178 (w)


________________________________
Privileged and Confidential. This e-mail, and any attachments there to, is
intended only for use by the addressee(s) named herein and may contain
privileged or confidential information. If you have received this e-mail in
error, please notify me immediately by a return e-mail and delete this
e-mail. You are hereby notified that any dissemination, distribution or
copying of this e-mail and/or any attachments thereto, is strictly
prohibited.


--

This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



Privileged and Confidential.  This e-mail, and any attachments there to, is
intended only for use by the addressee(s) named herein and may contain
privileged or confidential information.  If you have received this e-mail in
error, please notify me immediately by a return e-mail and delete this
e-mail.  You are hereby notified that any dissemination, distribution or
copying of this e-mail and/or any attachments thereto, is strictly
prohibited.


--

This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



Privileged and Confidential.  This e-mail, and any attachments there to, is
intended only for use by the addressee(s) named herein and may contain
privileged or confidential information.  If you have received this e-mail in
error, please notify me immediately by a return e-mail and delete this
e-mail.  You are hereby notified that any dissemination, distribution or
copying of this e-mail and/or any attachments thereto, is strictly
prohibited.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.