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