And what was wrong with the solutions you got in the other thread?
I have to agree with howardpc:
Give some input strings and the expected output with various values of ALevel, ALength and BLength.
And please make sure that the examples are "clear and obvious" so to speak.
Also, what is the bigger picture here?
What is your application going to do when it's finished?
Your current approach might very well be not the best one.
Nested functions are no different from "normal" function, but they are only accessible from within the procedure or function they are nested in.
Given these declarations:
procedure A;
begin
end;
procedure B;
procedure C;
begin
end;
begin
...
C;
end;
Now this:
will compile, but since C is only visible inside B this won't:
A;
B;
C; //<== compilation error
Bart