× 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.



Yes, I was in a hurry.  What you wrote is exactly what I was looking
for.  I should have been more clear.  I apologize.

Thanks
George

>>> klemscot@xxxxxxxxxxxx 03/23/04 11:58 PM >>>

Hi George,

My reply is below...

> Yeah.. My Example is bad... But, is there a way to convert the hex
value
> to a character or integer without doing it this way?

The waters are a bit muddy here.  I think the biggest confusion arises
from the code that you posted, which wouldn't work -- in fact, it
wouldn't
even compile.  But, I get the impression that this was just because you
wrote the e-mail quickly, and didn't actually cut/paste working code,
but
rather just typed it in quickly.  Is that right?   In other words, you
understand how to do it, you're just not sure if there's a better way?

In other words, this is what I THINK you meant to post:

     D Variable        ds                  qualified
     D    SizeChar                    2A
     D    SizeInt                     5I 0 overlay(Sizechar:1)
      /free
             Variable.SizeChar = x'0003';
             if Variable.SizeInt > 0;
             endif;
      /end-free

Is that correct?  And, I assume that you know that the "if" statement
will
always be true because 3 is always going to be larger than 0?  I'll
assume
that you understood all of that.

Now, my question is, are you looking for a way to convert hexidecimal
numbers to decimal numbers?  In other words, is the point of this
exercise
to convert x'F0' to 240?  Or is the point of the example to get the
character that corresponds to code point 240 in the character set that
your job is set to?

If you're looking for the former, you probably want the cvtch() MI
built-in.  Search the archives for it, you should have no problem
finding
code examples.

If you're looking for the latter, than the code you posted is probably
the
best way.  However, I'd do it slightly differently, I'd do it like this:

The following code snippet displays the codepoint of the 'X' character:

     D Codepoint       ds                  qualified
     D    Char                        1A
     D    Val                         3U 0 overlay(Char:1)
      /free
            Codepoint.Char = 'X';
            dsply ' ' ' ' CodePoint.Val;
      /end-free

What I did differently is that I used "3U 0" instead of "5I 0" because
when you do this type of thing, usually you're not interested in which
bits produce negative numbers, you only want the EBCDIC value of a the
character...   plus, you're generally working with 1 character at a
time,
and you don't want to fool around with a second character, so I used a 1
byte integer instead of a 2-byte integer.

However, there's no approach that I recommend for every situation.  You
have to handle your application in the appropriate way for what it does.
Since you didn't say anything about the business problem you're trying
to
solve, all I can do is suggest improvements to your code.  If you post
the
actual problem you're trying to solve -- then I can tell you how I'd
tackle that problem, which is usually a more useful answer.

Anyway, hope that helps...

_______________________________________________
This is the RPG programming on the AS400 / iSeries (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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.