Scott & Robert

Seems we had this thread just a short while ago. So I have a question.

In ASCII it works to add 1 to the value, since the entire alphabet is contiguous. Could one declare the ebcval variable as an ASCII code page and use that technique here?

Vern

-------------- Original message --------------
From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>

I guess it depends on what you want to happen when the character is
"incremented". If you just want to add one to the EBCDIC value of the
letter, you can do that easily by overlaying the character in a data
structure.

D ds
D char 1a
D ebcval 3u 0 overlay(char)

CHAR = 'A';
EBCVAL += 1;

After this code runs, CHAR would contain 'B'. (Because the EBCDIC value
for A is 193. Add 1, you get 194. The EBCDIC value for B is 194)

However, if you add 1 to 'I', you will NOT get 'J', since I is 201 and J
is 209 in EBCDIC, they aren't contiguous. And this is why folks are apt
to use an array for this sort of thing.


Robert Munday wrote:
Greetings from sunny Florida (where it has thunderstormed every day for the
past five weeks).

Without using arrays (I can do that), is there a way to increment a character
value?

CHAR = 'A';
CHAR += 1;

does not work, but is there something similar which would? I am adding a
two-character suffix to a field which increments `AA`, `AB`, `AC` etc.

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

This thread ...


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

This mailing list archive is Copyright 1997-2019 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].