# Loading variables from a txt file

**URL:** https://forum.kirupa.com/t/loading-variables-from-a-txt-file/7144
**Category:** Uncategorized
**Created:** [October 24, 2002, 3:14pm UTC](https://forum.kirupa.com/t/loading-variables-from-a-txt-file/7144 "2002-10-24T15:14:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![noodles101](https://avatars.discourse-cdn.com/v4/letter/n/b77776/32.png) [@noodles101](https://forum.kirupa.com/u/noodles101)
#### Post date: [October 24, 2002, 3:14pm UTC](https://forum.kirupa.com/t/loading-variables-from-a-txt-file/7144/1 "2002-10-24T15:14:59Z")

</div>

Hi,

I’m trying to load some variables dynamically from a text file,  
when a button is pressed. They will not load on first press , but on second  
or subsequent presses they will.

Anyone any ideas ???

Noodles…

numCatalog=0;

portf4.onRelease = function() {  
loadVariables(“images/cg.txt”,"");  
trace(numCatalog);  
};

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [October 24, 2002, 5:16pm UTC](https://forum.kirupa.com/t/loading-variables-from-a-txt-file/7144/2 "2002-10-24T17:16:07Z")

</div>

You’re tracing the variable too soon. The data has not arrived yet. One solution would be to have a variable at the end of your file and check if that variable has arrived yet. Then you can trace what you want.

If you’re running the code locally, you have to wait at least one frame before you can trace loaded data.

pom :cool:
