Hmm. is the ENDIG a typo or is it in your script?
Make sure all your IFs match ENDIFs ... is this the complete script? If there is more that you're leaving out, may we see it?

Brian