> done, but I much prefer the loop version to the last version.
>
> Can't you use a macro processor to generate the verbose code? ;-)
 
Yes, I would use the Pascal Macro Compiler for this chore, but whether I code it by hand or generate using the PMC, my program still would contain the verbose code.

> Anyway, I see that this is an example, at least in theory. However,
> I'd probably do it differently in practice. I think this is more
> efficient, since you don't need any comparisons, and in particular
> no extra code in the innermost loop which is the most time-critical.
> If you need the original start values afterwards, copy the array
> before the first loop, of course.
>
>  for a1 := start[1] to max[1] do
>    begin
>      for a2 := start[2] to max[2] do
>        begin
>          for a3 := start[3] to max[3] do
>            begin
>              ...
>            end;
>          start[3] := 1
>        end;
>      start[2] := 1
>    end;
>
> Frank
This is much nicer code than my version.  However I would still choose to make the loop control variables a[1], a[2], a[3], etc., so that when I take the checkpoint the checkpointing procedure could use a loop like
 
for  n := 1 to depth  do
  writeln (checkfile, a[n]);
 
Incidentally, when I do this in practice I do not usually test for interruptions at every level in the nested loops.  If the loops are nested 30 levels deep I might test for user interrupts only at levels 5, 10, 15 and 20.  However, if the interrupt occurs at, say, level 15, you still need to write all of the control variable values from 1 through 15 to the checkpoint file.
 
Frank Rubin