If you look hard at the logic, you'll see what's happening. It can never get
through the FOR/NEXT loop any time your IF/THEN block evaluates as TRUE.

When this happens, as you mentioned previously;
If result = ...THEN" test always passes
That is exactly what causes this;
placed in a FOR NEXT loop ... program hangs up !!!
Because GOTO Start is inside your loop, inside the IF/THEN block that always
evaluates as TRUE.
Code:
Start:

  result = 0

For I = 1 to 16....
  GOSUB Thesub
  PULSIN input,1, value

  ' If this next part "always" evaluates TRUE, then you'll never make it
  ' past FOR I = "1". You keep jumping back to Start & restarting
  ' the FOR/NEXT loop

   IF (value < A) OR ( value > B ) then
     error = 1 ( it's a red led ! )
     value1 = ...
     value2 = ...
     GOTO Start  ' <-- restarts FOR/NEXT loop over & over & over, etc,,
   ENDIF           ' while IF/THEN evaluates as TRUE
   result = result + value
NEXT I

   result = result >> 4 ( the mean value ....)

TheSub:
   Low out1
   Pulsout out1,value1
   Low out2
   Pulsout out2,value2
   RETURN
Now let's assume the statement IF (value < A) OR ( value > B ) then
never ends up being TRUE. You go through the FOR/NEXT loop until it expires,
fall-through into TheSub, land on the RETURN, and you now have another big
problem.

RETURN pops the return address from the stack. Where is your program going
to return to if the address is invalid...?