# LoadVars problem - With a lemony twist

**URL:** https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374
**Category:** Uncategorized
**Created:** [August 13, 2003, 3:32am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374 "2003-08-13T03:32:13Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Coppertop](https://avatars.discourse-cdn.com/v4/letter/c/839c29/32.png) [@Coppertop](https://forum.kirupa.com/u/Coppertop)
#### Post date: [August 13, 2003, 3:32am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/1 "2003-08-13T03:32:13Z")

</div>

Alright, I’m creating a site for a local band. I’ve decided to create a system where he (the webmaster - also lead guitarist) has the site, and a bunch of .txt files that will load into them. By having the txt files set as a bunch of html code, he can format it as he wishes and get colours and italics and what not.  
Well, for the news section, instead of loading one MASSIVE file, of all the bands doings, it will be one text file per entry with two variables, one for the news, one for the date.  
each .txt file has a numbered name, 1 being the first 10 (for example) the most recent. I have another txt file that has the number of entries. Simply, the thing loads the file, and then takes the top number as the most recent, genius huh?

well, kinda. I’m having a bit of trouble with the strings. What the hell am I doing wrong? I’m sure its a simple answer.

```auto
loadtotal = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	loadText = new LoadVars();
	loadText.load((loadtotal add ".txt")); //--this is the trouble area I am sure.
	loadText.onLoad = function() {
		one.text = this.news;
		two.text = this.updates;
	};
};

```

---

<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: [August 13, 2003, 3:38am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/2 "2003-08-13T03:38:56Z")

</div>

Whats the format of your total-number.txt file?

---

<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: [August 13, 2003, 3:40am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/3 "2003-08-13T03:40:30Z")

</div>

why are you declaring a new load vars within the onLoad event… im confused 🙂

---

<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: [August 13, 2003, 4:08am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/4 "2003-08-13T04:08:18Z")

</div>

Jubba: well, currently its just txt. If I put it in HTML 1.0, and turn on render as HTML on the text box, then it should display as html

Ahmed: I did that because I used kirupa’s tutorial and realised that this new loadvars is only to be executed AFTER the thing has loaded. but do you think it might be the cause of the problem?

---

<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: [August 13, 2003, 4:10am UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/5 "2003-08-13T04:10:17Z")

</div>

I mean how is it set up. like

num=10

whats the variable name…

---

<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: [August 13, 2003, 5:31pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/6 "2003-08-13T17:31:06Z")

</div>

well, it goes as follows:

Total number of entries variable name: total

entry content: news  
date: update

I will change them though for the sake of the band so its: content and date

---

<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: [August 13, 2003, 6:29pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/7 "2003-08-13T18:29:02Z")

</div>

ARGH! forget it. Here is the .fla, can you tell now what I am doing wrong?

---

<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: [August 13, 2003, 6:40pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/8 "2003-08-13T18:40:04Z")

</div>

I see on the 5th line you are loading a file.  
[AS]loadText.load(loadtotal add “.txt”);[/AS]

but loadtotal is a loadVars object.

Is a variable that you are loading from original file to be used to load the second file?

---

<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: [August 13, 2003, 6:40pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/9 "2003-08-13T18:40:41Z")

</div>

Here

---

<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: [August 13, 2003, 6:54pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/10 "2003-08-13T18:54:11Z")

</div>

Thanks claudio! well, it loaded the file, which is good, I got it to do that.

I’ll reword my problem:

Ok, first off, I load a variable containing the total number of posts:

```auto
loadtotal = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
};

```

This works. No problems there. Next, I want to load the most recent item of news (which is the text file with the highest number as it’s file name) so, that would be someting like this:

```auto
loadtotal = new LoadVars();
loadstuff = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
	loadstuff.load(total add ".txt");
	loadtotal.onLoad = function() {
		one.text = this.content;
		two.text = this.date;
	};
};

```

This on the other hand, does not work. It will load the total number, but not the content. What am I doing wrong?

[edit]never mind! i got it to work! there was a typo in the script because I copied and pasted. the proper script goes as such:

```auto
loadtotal = new LoadVars();
loadstuff = new LoadVars();
loadtotal.load("total-number.txt");
loadtotal.onLoad = function() {
	three.text = this.total;
	total = this.total;
	loadstuff.load(total add ".txt");
	loadstuff.onLoad = function() {
		one.text = this.content;
		two.text = this.date;
	};
};

```

Thanks to everyone who helped![/edit]

---

<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: [August 13, 2003, 7:11pm UTC](https://forum.kirupa.com/t/loadvars-problem-with-a-lemony-twist/28374/11 "2003-08-13T19:11:39Z")

</div>

np :thumb:
