# If statement & setInterval wont work?

**URL:** <https://forum.kirupa.com/t/if-statement-setinterval-wont-work/85914>\
**Category:** Uncategorized\
**Created:** [April 8, 2005, 11:29am UTC](https://forum.kirupa.com/t/if-statement-setinterval-wont-work/85914 "2005-04-08T11:29:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakob](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yakob/32/348_2.png) [@yakob](https://forum.kirupa.com/u/yakob)\
**Post date:** [April 8, 2005, 11:29am UTC](https://forum.kirupa.com/t/if-statement-setinterval-wont-work/85914/1 "2005-04-08T11:29:47Z")

</div>

hey out there,

i’ve a real simple battery level monitor that’s fictitiously sets a level indicator.

there’s a function that’s called using setInterval:

```auto

stop();
batLevelNo=100;
batLevel="(100%)";
function setBatLevel() {
	batLevelNo = batLevelNo-20;
	batLevel = "("+batLevelNo+"%)"
	bar._x = bar._x-5;
}
if (batLevelNo > 0){
	setInterval(setBatLevel, 500);
}

```

the thing is, i want to stop calling the function when the batLevelNo gets to 0 - but the:

```auto

if (batLevelNo > 0){
	setInterval(setBatLevel, 500);
}

```

doesn’t work, it just keeps going.

i have a feeling this is something obvious and i’m being a spoon, does anyone have any suggestions?!

many thanks,

jake
