# For loop variables/arrays

**URL:** <https://forum.kirupa.com/t/for-loop-variables-arrays/7781>\
**Category:** Uncategorized\
**Created:** [November 7, 2002, 4:42pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781 "2002-11-07T16:42:37Z")\
**Posts on this page:** 10\
**Page:** 2

<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:** [November 9, 2002, 4:09pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/21 "2002-11-09T16:09:57Z")

</div>

yep, it would be useful 🙂

---

<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:** [November 9, 2002, 6:44pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/22 "2002-11-09T18:44:14Z")

</div>

```auto

//read the text file "legends.txt"
myvars=new loadVars();
myvars.load("legends.txt");
//when the text file fully loads, perform some actions
myvars.onLoad=function(){
	_root.statbox.text="loaded"; //just say loaded at top right of screen
//establish new arrays (lotinfo) that are the loaded variables split into arrays;

	for(i=1;i<5;i++){
	
		myref=this["lot"+i];//reference to the variable lot plus the value of i
		trace(myref);
		lotinfo1=myref.split(","); /*KIRUPA HELPERS! This is where instead of lotinfo1,
		I would like it to give me lotinfo1, lotinfo2, lotinfo3, etc.. (as it goes through
		the values of i).
		*/
			
				}
}

```

the legends.txt file simply reads lot1=sold,pic1.jpg&lot2=available,pic2.jpg&lot3=pending,pic3.jpg

so and so forth.

I hope this helps clarify.

Thanks a million.

---

<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:** [November 10, 2002, 6:50pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/23 "2002-11-10T18:50:18Z")

</div>

bump…since it is pending

---

<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:** [November 10, 2002, 6:51pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/24 "2002-11-10T18:51:49Z")

</div>

I lost what u need when i saw that code!

---

<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:** [November 10, 2002, 7:14pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/25 "2002-11-10T19:14:11Z")

</div>

```auto
lot1="sold,pic1.jpg";
lot2="available,pic2.jpg";
lot3="pending,pic3.jpg";
for(var i=1;i<4;i++){
	myref=this["lot"+i];//reference to the variable lot plus the value of i
	trace(myref);
	_root["lotinfo"+i]=myref.split(",");
}

```

This seems to do the job.

pom 🙂

---

<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:** [November 10, 2002, 7:16pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/26 "2002-11-10T19:16:56Z")

</div>

could u explain ur code ilyas, or something wrong with me today! :sleep:

---

<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:** [November 10, 2002, 7:20pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/27 "2002-11-10T19:20:39Z")

</div>

Well, there’s not much to explain, h88. Since the text is loaded, I just declared the strings that are loaded, and then 3 arrays (created by the split) are created on the \_root.

Or am I off course?

---

<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:** [November 10, 2002, 7:21pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/28 "2002-11-10T19:21:42Z")

</div>

thats it, i got it!

---

<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:** [November 10, 2002, 8:00pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/29 "2002-11-10T20:00:26Z")

</div>

That’s the ticket, Pom. I don’t know what happened, but I tried that way in one of my attempts, and it did not work. That is really, really weird. Anyway, that certainly gets me back on track. Thanks!

---

<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:** [November 10, 2002, 8:01pm UTC](https://forum.kirupa.com/t/for-loop-variables-arrays/7781/30 "2002-11-10T20:01:43Z")

</div>

as a matter of fact, I checked one of the earlier versions and it says exactly that, when I ran it, still gave me assignment error. I cut the text, pasted it again, and it worked! How is that for fun?

[Previous page](https://forum.kirupa.com/t/for-loop-variables-arrays/7781.md?page=1)
