Increment special value in I6

So I have this channel identifier that in the past has been like this:

Constant FYC_MAIN = ('M' * $1000000) + ('A' * $10000) + ('I' * $100) + 'N';

I still need to keep the standard channels because they’re known internally by fyrevm.

But any new channel doesn’t need any special identifier. It can be any unique number outside of those standard identifiers.

So I was thinking I could start new channels at ZZAA and increment through ZZZZ. This would be more than enough channels.

What would be the easiest algorithm to increment the value if it started as:

Global next_channel_identifier = ('Z' * $1000000) + ('Z' * $10000) + ('A' * $100) + 'A';
Test Chamber is a room.

Include (-

#ifndef TARGET_GLULX;
Message fatalerror "This program is Glulx-only.";
#endif;

Global next_id = 0;

[ GetNextId id;
  if (next_id >= 26*26) {
      print "*** GetNextId: out of channel identifiers ***^";
      next_id = 0;
  }
  id = ('Z' * $1000000) + ('Z' * $10000) + (('A' + next_id / 26) * $100) + ('A' + next_id % 26);
  next_id++;
  return id;
];

-).

To decide which number is the next id:
	(- GetNextId() -).

When play begins:
	repeat with i running from 0 to 100:
		say "[the next id] ";

That much nicer than mine:

Include (-

Global root_channel = 1515864320;
Global current_channel = 1515864320;
Global channel_index = 0;

[ GET_NEXT_CHANNEL_NUMBER;

	channel_index++;
	
	if (channel_index == 25) {
		channel_index = 0;
		root_channel = root_channel + 256;
	}
	
	current_channel = root_channel + channel_index;

	return current_channel;
];

-);

Okay now I want to turn one of these numbers back into a 4 letter string on the I7 side.

This is pretty clunky.

Include (-

[ Extract id n  byte;
   if (n < 0) n = 0;
   if (n > 3) n = 3;
   for ( : n >= 0: n-- ) {
       byte = id % 256;
       id = id / 256;
   }
   return byte;
];

-).

To decide which Unicode character is char (N - number) in (id - number):
	(- Extract({id}, {N}) -).
	
To decide which text is the string of (id - number):
	decide on "[char 3 in id][char 2 in id][char 1 in id][char 0 in id]".

When play begins:
	let foo be the next id;
	say "[the string of foo]";

Thanks!