# Making a variable available outside a function

**URL:** https://forum.kirupa.com/t/making-a-variable-available-outside-a-function/179507
**Category:** Uncategorized
**Created:** [February 20, 2006, 9:56pm UTC](https://forum.kirupa.com/t/making-a-variable-available-outside-a-function/179507 "2006-02-20T21:56:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Goth\_Santa](https://avatars.discourse-cdn.com/v4/letter/g/46a35a/32.png) [@Goth\_Santa](https://forum.kirupa.com/u/Goth_Santa)
#### Post date: [February 20, 2006, 9:56pm UTC](https://forum.kirupa.com/t/making-a-variable-available-outside-a-function/179507/1 "2006-02-20T21:56:16Z")

</div>

Basically I’m trying to load a variable from an external file and then make that variable available for anything.

```auto

var where;
locSource = new LoadVars ();
locSource.load("source.txt");
locSource.onLoad = function () {
    where = this.loc;
}
trace (where);

```

I’ve tried all the variations of this I can think of. I’ve defined “where” as a global variable both outside and inside the function, tried to define a separate global value within the function (and changed the syntax of the trace accordingly in either case), nothing works. Basically, the function is being loaded properly; if I put the trace inside the function it shows up perfectly, but the variable isn’t available for anything else, which is what I need to happen. Any ideas?
