# HELP! using a variable from a function

**URL:** <https://forum.kirupa.com/t/help-using-a-variable-from-a-function/113646>\
**Category:** Uncategorized\
**Created:** [June 20, 2004, 11:19am UTC](https://forum.kirupa.com/t/help-using-a-variable-from-a-function/113646 "2004-06-20T11:19:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fredde\_pe](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@fredde\_pe](https://forum.kirupa.com/u/fredde_pe)\
**Post date:** [June 20, 2004, 11:19am UTC](https://forum.kirupa.com/t/help-using-a-variable-from-a-function/113646/1 "2004-06-20T11:19:57Z")

</div>

Hi,

Probably a simple question but I’m new to this.

I’m retrivning a value from a textfile. The value is a path to a folder containg images. The value retrieved from thePics variable is images/test/

Now my problem, I want the variable test to contain the value from thePics variable. My problem is that the test variable is only accessible inside the function (see comment)

myLoadVars.onLoad = function(success){  
if (success){  
this.test = myLoadVars.thePics; //  
trace(this.test); //correct value here  
}else{  
trace(“no variables loaded”);  
}  
};

//Here is where I want my test variable with the path “images/test/”  
this.pathToPics = (test);

The path is the path to the folder, when correct the firstFile.jpg shoud be displayed. If I declare the test variable with:

test = (“images/dragar2/”); everyting is working fine, but not when I retrive it from the textfile inside the function.

Thanks
