If you would want to optimize it a bit, i would first get rid of NextChar() function. You could put all valid characters in a string constant, something like
Code:
const validstr = 'abcd....ABCD....XYZ0123456789';
Then matter of changing character is simply increasing character index by 1.

Code:
index:=1;
validstr[index] is 'a'
inc(index);
validstr[index] is now 'b'