# Pulling a variable out of this function as a return?

**URL:** <https://forum.kirupa.com/t/pulling-a-variable-out-of-this-function-as-a-return/185281>\
**Category:** Uncategorized\
**Created:** [April 12, 2006, 6:02am UTC](https://forum.kirupa.com/t/pulling-a-variable-out-of-this-function-as-a-return/185281 "2006-04-12T06:02:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flaevo](https://avatars.discourse-cdn.com/v4/letter/f/bbce88/32.png) [@Flaevo](https://forum.kirupa.com/u/Flaevo)\
**Post date:** [April 12, 2006, 6:02am UTC](https://forum.kirupa.com/t/pulling-a-variable-out-of-this-function-as-a-return/185281/1 "2006-04-12T06:02:44Z")

</div>

Scripting File

```auto
_global.counter = function() {
    if (!counterId) {
        counterId = 0;
    }
    counterId++;
    return (counterId);
};
_global.incValues = function() {
    // Values
    this.getValues = function(startValue, endValue) {
        // Make New Array
        incArray = new Array();
        // arrange high to low loop
        if (startValue>=endValue) {
            for (i=startValue; i>=endValue; i--) {
                incArray[Math.abs(i-startValue)] = i;
            }
            incArray.reverse();
        }
        // arrange low to high loop            
        if (startValue<=endValue) {
            for (i=startValue; i<=endValue; i++) {
                incArray[Math.abs(i-startValue)] = i;
            }
            incArray.reverse();
        }
        return (incArray);
    };
    // Interval Switch
    this.intSwitch = function(incArray, intLength) {
        incLength = incArray.length;
        interval = function () {
            incLength--;
            if (incLength<=0) {
                clearInterval(intSI);
            }
            finalValue = incArray[incLength]; // THIS VARIABLE <---------
        };
        intSI = setInterval(interval, intLength);
    };
};
stop();

```

Main File

```auto

#include "scripting.as"
boxIncValues = new incValues();
arrayvalues = boxIncValues.getValues(0, 100);
boxIncValues.intSwitch(arrayvalues, "100");
stop();

```

Basically I would like to beable to pull that variable from the functions as a return or a non-assigned variable so I can use them seperately to apply alpha/position ect… to objects.

---

<div class="post-metadata">

**Author:** ![FizixMan](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@FizixMan](https://forum.kirupa.com/u/FizixMan)\
**Post date:** [April 12, 2006, 3:25pm UTC](https://forum.kirupa.com/t/pulling-a-variable-out-of-this-function-as-a-return/185281/2 "2006-04-12T15:25:56Z")

</div>

Perhaps add them to the \_global array of variables?
