# Scary change of var values

**URL:** <https://forum.kirupa.com/t/scary-change-of-var-values/177160>\
**Category:** Uncategorized\
**Created:** [January 30, 2006, 7:48pm UTC](https://forum.kirupa.com/t/scary-change-of-var-values/177160 "2006-01-30T19:48:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cup\_of\_tea](https://avatars.discourse-cdn.com/v4/letter/c/4af34b/32.png) [@cup\_of\_tea](https://forum.kirupa.com/u/cup_of_tea)\
**Post date:** [January 30, 2006, 7:48pm UTC](https://forum.kirupa.com/t/scary-change-of-var-values/177160/1 "2006-01-30T19:48:15Z")

</div>

[Edit] Found out that another function was running concurrently and changing x’s value. :block: \<- block head = me

I have two functions, flatline2() and lines(). In flatline2() I’ve set x=0, but when I call lines() the var x as well as other vars are incremented by one.

```auto
**flatline2** =function(leninter){
 
 _global.x++;
 pen2.lineTo(_global.x*magnify,0 *magnify);
 
 if (intx==leninter){
  clearInterval(flat2);
  complex2=setInterval(lines2,drawspeed);
 }
 
 if (_global.x==endofscreen){
  clearInterval(flat2);
  arraystart=count;
  pen2.swapDepths(pen1);
 
  [COLOR=red] **_global.x=0;**
[/COLOR]
  pen1.clear();  
   pen1.lineStyle(2, 0x00ee00, 100);
  pen1.moveTo(_global.x*magnify,ekgarr[arraystart]*magnify); 
 
   **[COLOR=red]trace("here x:"+_global.x+" count:"+count+"arraystart:"+arraystart); [/COLOR]**
[COLOR=red]
**pattime=setInterval([COLOR=black]lines[/COLOR],drawspeed);**[/COLOR]
 
 }
 
 intx++;
 
} 

```

```auto
**lines** =function(){
   **[COLOR=red]trace("x"+_global.x+"count"+count);[/COLOR]**.
.
.
etc.

```

Trace output looks like this:

```auto
here x:0 count:0arraystart:0
x1count1

```

Any clue to what’s going on?
