Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I parse text files to sort out keywords 2

Status
Not open for further replies.

HectorCollector

Programmer
Apr 1, 2004
7
SE
I like to import a textfile to flash and then parse through it to sort out keywords. Is it possible to sort out characters too like you can with the c-command getchar?
 
A couple of functions that might help - the first looks for a word and splits the input phrase up into an array around the keyword, the second grabs each character in succession.

Code:
formatText = function (input) {
	var tempArr = input.split("to");
	trace(tempArr[0]);
	trace(tempArr[1]);
};
//
getCharacters = function (input) {
	for (var i = 0; i<input.length; i++) {
		trace(input.charAt(i));
	}
};
//
string = "text string to be formatted by function";
formatText(string);
getCharacters(string);
 
Thanks Wangbar!

Your functions work out fine! Do you also know how I get the textfile, "datatext.txt" into the string I send to the functions?
 
To load the textfile into Flash in the first place you have to have its contents in the form of a variable anyway and Flash will read that as a string by default.

So your textfile would be set up something like this:

Code:
&textContent=all of the text that I want to parse in Flash...

When Flash reads this in the variable 'textContent' will contain all of your data and you pass that variable to the functions for parsing.

If you want to add more variables you could have:

Code:
&textContent1=some of the text that I want to parse in Flash]&textContent2=more of the text that I want to parse in Flash





 
Thank you again!

This works out fine but the problem is that I don´t set up the textfile for myself. The file is my downloadeded e-mails who are saved by Outlook express into an textfile. Maybee you know how to automate the textfile so it always begins with &textContent every time it´s updated by Outlook? An even better solution could be to not using the Outlook at all and instead writing a program in actionscript who login to my mailserver and get the e-mails directly to my Flash application. Do you know how to do this or where I could find out?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top