From: Scott Klement
I don't understand.  Why do you think this would be easier to do in RPG
than it is in CL?  What would you do differently in RPG than you'd do
with a CL solution?
The way I read it was that there is an "alpha sequence number", which means
to me a number of characters that could spin, sort of like an odometer, only
through alpha numbers.
The way I would do it would be to have a string of characters that I could
"increment" through, such as 'ABCDEFGHI...XYZ'.  Then I'd take the current
value, and starting at the right-most character, I'd find it's position in
the array using the %scan BIF and add one to it.  If the resulting position
was longer than the array, I'd set a "carry" flag and then set the position
of the rightmost character to 1.  If the carry flag was set, I'd do the same
thing for the next position to the left.
// RIGHTCHAR = index of rightmost character to spin
// CHARS_THAT_SPIN = number of characters that spin
// SPINCHARS = field initialized to characters to spin through
I = RIGHTCHAR;
Dou NOT carry;
  X = %scan(%subst(field:I:1):SPINNER);
  If X = 0;
    // FATAL ERROR
  Elseif X = %Len(SPINNER);
    Carry = *on;
    X = 1;
  Else;
    X = x + 1;
  Endif;
  %subst(field:I:1) = %subst(SPINNER:X:1);
  I = I - 1;
  If (RIGHTCHAR - I) > CHARS_THAT_SPIN;
    // OVERFLOW
  Endif;
Enddo;
I'm not sure how I'd do that in CL.  I mean, it COULD be done, but it would
be pretty ugly, especially replacing the %scan BIF.
Am I missing something obvious, Scott?
Joe
 
As an Amazon Associate we earn from qualifying purchases.