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



Actually, it's almost the same as in other languages:

     D char            DS                  Qualified
     D  text                          1A
     D  dec                           3U 0 Overlay(text)
     
     C                   eval     char.dec += 1

Yes, I know that when you jump the character group boundary it doesn't work, but
I'm responding to Don't comment in this email.

-Bob Cozzi
www.iSeriesTV.com
iPod your industry news instead of reading it.
Coming June 2006
Ask your friends to watch iSeriesTV.com

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Don Wereschuk
Sent: Tuesday, May 30, 2006 7:13 AM
To: RPG programming on the AS400 / iSeries
Subject: RE: Add to Character Value

Thanks Scott and all others who replied. You had the idea right when you
said A = 193 and adding 1 would give me 194 which is B. I was unable to
convert the character 'A' to a numeric value, add 1 to it and convert
the numeric value back to a character ( in this case it should be 'B')
This is simple to do with ASCII codes but it looks like not with EBCDIC.
I should have known better. I guess I'll have to use an array which I
didn't want to do but I have no other choice. Again Thanks to all who
responed.


******************************************
Don Wereschuk
ISD Associate - Programmer
Simcoe Parts Service Inc.
Phone:   705-435-7814          Ext.: 302
Fax:         705-435-6746
dwereschuk@xxxxxxxxxxxxxxx
******************************************
-----Original Message-----
From: Scott Klement [mailto:rpg400-l@xxxxxxxxxxxxxxxx] 
Sent: Monday, May 29, 2006 4:20 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Add to Character Value


Hi Don,

Does anyone know of a method to increment a character value . For
instance I want to increase the value 'A' to be the value 'B'.

The trouble with your question is that it can be interpreted two
different 
ways.  Either you want to increase the EBCDIC value of the letter by 1,
or 
you want to move to the next letter in sequence.  Your message wasn't 
specific.

The EBCDIC value of A is 193.  Adding 1 will give you 194, which is B. 
However, the EBCDIC value of I is 201, adding 1 would yield 202 which is

_not_ J.  (J is 209).

So it's not clear to me what precisely you're looking for.  To add to
the 
EBCDIC value of a character, overlay the character with binary number. 
When you add to the binary number, you change the EBCDIC value.  For 
example:

      D                 ds
      D   char                         1A
      D   val                          3U 0 overlay(char)

       /free

          char = 'A';
          val = val + 1;

          // char is now 'B'
       /end-free

If you want the next alphabetic character without regard to the EBCDIC 
sequence, then load all of the letters into an array and add 1 to the 
array position:

      D alphabet        s             26A   inz('ABCDEFGHIJKLM-
      D                                     NOPQRSTUVWXYZ')

      D char            s              1A
      D val             s             10I 0

       /free

          char = 'I';

          val = %scan(char:alphabet);
          val = val + 1;
          char = %subst(alphabet:val:1);

          // char is now J

       /end-free

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.