>
> hi,
> many thanks !! now I could fix it with your help (there was a  
> further "end"-mistake in the output routine..) but do you know any  
> tricks or meassures to avoid these deep nestings while coding or  
> keep track of the begins and ends of ones code?
>
Code folding is one way. In TextMate for example, it is easy to see  
if you put end in enough times.
One other thing is to put a comment after an 'end' to tell you what  
it is ending.

C-like languages can be just as much trouble with closing braces.