Check your scope DIM/GLOBAL perhaps you're stepping on another variable. Also check for missing IF/ENDIF or other syntax errors in the main script.