# I'm gonna cry: reading variables from line in textfile

**URL:** <https://forum.kirupa.com/t/im-gonna-cry-reading-variables-from-line-in-textfile/264350>\
**Category:** flash\
**Created:** [June 25, 2008, 8:18am UTC](https://forum.kirupa.com/t/im-gonna-cry-reading-variables-from-line-in-textfile/264350 "2008-06-25T08:18:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fledermaus](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@fledermaus](https://forum.kirupa.com/u/fledermaus)\
**Post date:** [June 25, 2008, 8:18am UTC](https://forum.kirupa.com/t/im-gonna-cry-reading-variables-from-line-in-textfile/264350/1 "2008-06-25T08:18:52Z")

</div>

I thought it would be quite easy to read variables from a textfile into flash, where the first line is the first variable, the second line is the second variable and so on.

I was wrong.

I already asked help in several ways but no go :crying: so I thought I might ask you, the specialists

Let me explain:

In a textfile, there are 7 lines:

```auto

&mondaystr=this is the menu for monday&
&tuesdaystr=this is the menu for tuesday&
&wednesdaystr=this is the menu for wednesday&
&thursdaystr=this is the menu for thursday&
&fridaystr=this is the menu for friday&
&saturdaystr=this is the menu for saturday&
&sundaystr=on sunday we rest&

```

So now I want to read those variables into flash. I use this code:

```auto

loadedText = loadVariablesNum("file.txt", 0);
var Menutoday = mondaystr;
var Menutomorrow = tuesdaystr;
var dayToday = dateToday.getDay();

```

Depending on the day it is, the Menutoday string and the Menutomorrow string should be calculated using a switch case thing.

Now, what’s the situation:

when I create a textfield with var mondaystr, it works. Also for the other days.  
when I create a textfield with var Menutoday, it says undefined?!

I don’t get it. It’s two days now that I’m working on this single issue and I’m afraid I’m completely stuck :sen:

Can someone help me out please?

Thanks in advance.

EDIT: maybe I should add the switch code too?

* * *

```auto

switch (dayToday) {
	case 0: Menutoday = sundaystr; 
			Menutomorrow = mondaystr;
			break;
	case 1: Menutoday = mondaystr;
			Menutomorrow = tuesdaystr;
			break;
	case 2: Menutoday = String(tuesdaystr);
			Menutomorrow = wednesdaystr;
			break;
	case 3: mealOfTheDay = tuesdaystr;
			Menutomorrow = wednesdaystr;
			break;
	case 4: Menutoday = tuesdaystr;
			Menutomorrow = wednesdaystr;
			break;
	case 5: Menutoday = tuesdaystr;
			Menutomorrow = wednesdaystr;
			break;
	case 6: Menutoday = tuesdaystr;
			Menutomorrow = wednesdaystr;
			break;
		}

```

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 25, 2008, 11:16am UTC](https://forum.kirupa.com/t/im-gonna-cry-reading-variables-from-line-in-textfile/264350/2 "2008-06-25T11:16:20Z")

</div>

why not try xml ? it is a perfect solution to this situation

although you can do with text file too… but xml is definitely fitting in 🙂

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 25, 2008, 11:39am UTC](https://forum.kirupa.com/t/im-gonna-cry-reading-variables-from-line-in-textfile/264350/3 "2008-06-25T11:39:45Z")

</div>

no not xml its an abbreviation!!! 😛
