# \# of Quotes in a FILE

**URL:** https://forum.kirupa.com/t/of-quotes-in-a-file/188657
**Category:** flash
**Created:** [May 9, 2006, 8:18pm UTC](https://forum.kirupa.com/t/of-quotes-in-a-file/188657 "2006-05-09T20:18:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![birenpatel](https://avatars.discourse-cdn.com/v4/letter/b/e0b2c6/32.png) [@birenpatel](https://forum.kirupa.com/u/birenpatel)
#### Post date: [May 9, 2006, 8:18pm UTC](https://forum.kirupa.com/t/of-quotes-in-a-file/188657/1 "2006-05-09T20:18:31Z")

</div>

Hello All, I’ve got the following script working for random quotes

var format = new TextField.StyleSheet();  
var path = “quotes.css”;  
format.load(path);  
format.onLoad = function(success) {  
if (success) {  
output.styleSheet = format;  
myLoadVar = new LoadVars ();  
myLoadVar.load(“Quotes.txt”)  
myLoadVar.onLoad = function (success){  
if (success == true) {  
RanNum = Math.ceil(Math.random()\*5);  
ran = this[“quote”+RanNum];  
output.htmlText = ran;  
}  
}  
} else {  
output.text = “Error loading CSS file!”;  
}  
};

My TASK is that, once i finish this project, someone else WITHOUT Flash Knowledge will be maintaining this. So what i wanted to do is create a .txt file for them to edit so they can put as many QUOTES as they want. NOw the problem is that the following “RanNum = Math.ceil(Math.random()\*5);” will look for 5 quotes in the TXT file, if i go any lower than 5 for example 2, I get UNDEFINED for those 3 that aren’t in there.

How do i get FLASH to go through the .txt FILE and automatically change “5” to the # of Quotes in the file?

FORMAT of .txt file:  
quote1=\<p class=‘quote’\>Test1\</p\>  
&quote2=\<p class=‘quote’\>Test2\</p\>  
&quote3=\<p class=‘quote’\>Test3\</p\>  
&quote4=\<p class=‘quote’\>Test4\</p\>

Appreciate any help that i can get. Thanks.
