search a text FILE BY FIRST CHAR OF WORD

This is a discussion on "search a text FILE BY FIRST CHAR OF WORD" within the Flash & Multimedia Forum section. This forum, and the thread "search a text FILE BY FIRST CHAR OF WORD are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 18th, 2003, 10:17
New Member
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
search a text FILE BY FIRST CHAR OF WORD

i need to create a flash based search engine where a user can enter a search string and then find the same string from a text file

for Example
text file contains : HELLO HOW ARE YOU. WHAT IS YOUR NAME. ARE YOU FEEL COOL ?. HI HOW ARE YOU. HE HAD HAHAHA HAHAH

AND USER INSERT : H H A

THEN OUTPUT SHOULD BE : HELLO HOW ARE YOU & HI HOW ARE YOU & HE HAD HAHAHAH

MEANS SEARCH UPON FIRST CHARACTER OF THE SENTENCE

  #2 (permalink)  
Old Aug 18th, 2003, 19:28
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
I will have a little bash at this and see what I can come up with!

You just want to search for the first character of the sentence?
  #3 (permalink)  
Old Aug 19th, 2003, 06:47
New Member
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Ok Just tell me i have a simple text file containing some running text line by line

text file example :

this is good.
this is bad.
This is cool.
This is ugly.


Now how to store each line in indvidual variable
  #4 (permalink)  
Old Aug 22nd, 2003, 10:01
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Ok I have solved your first question entirely and have uploaded a FLA file which does exactly what you want. It was a bit of a challenge actually!

I have included plenty of comments in the code, which you will find by right-clicking on the "Search" button and clicking on actions.

Sorry if you're not fluent with general programming or actionscript. If you are fluent with general programming principles then this shouldn't be too hard to pick up. If not then please ask us questions about what you don't understand and we as a forum will do our best to help you out.

You will find the online version here:
http://www.digital-end.com/webforumz...ch_engine.html

You can edit both the input and searchable sentences.

And here is the FLA:
http://www.digital-end.com/webforumz...rch_engine.fla

In response to your last question:
"Ok Just tell me i have a simple text file containing some running text line by line?"
Well, I split it by sentences ". " but you can also do line by line by telling flash to split it by "\n" which in text terms is a new line.

Hope i've been of some help to you!
  #5 (permalink)  
Old Aug 22nd, 2003, 10:04
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Oh and for those of you who are lazy, here is the code:

Code: Select all
<textarea cols=70 rows=20>
on (release) {
	// Firstly, clear the last search by making output nothing.
	output = "";

	// Split searchable text into our array by full stop.
	sentences = searchtext.split(". ");
	// 
	// Set up loop to search through each sentence for each of the search items.
	// Set "count" to 0 so we can loop through the search items and go through each
	// item of our array by using count.
	count = "0";
	
	// Split up the searchitems  into an array by space, commas could be used instead.
	searchitems = input_t.split(" ");
	
	// Get the length of out new arrays
	noofsearchitems = searchitems.length;
	noofsentences = sentences.length;
	
	// Here is our first while loop, which will look until count is no longer
	// equal less than the number of searchitems. This loops through each of the
	// items the user has entered to search for.
	while (count<noofsearchitems) {
		// Trace is drawn on screen when you test in flash - This is for debugging.
		trace("Search: "+searchitems[_root['count']]);
		// Set count 2 to 0 - This must happen for each search of the sentences
		// otherwise you will not search for each letter entered.
		count2 = "0";
		// Our second while loop checks through each of the sentences.
		while (count2<noofsentences) {
			// Another trace for debugging.
			trace("Sen: "+sentences[_root['count2']]);
			// This compares the first character of the sentence in the array
			// and compares it to the searchitem.
			// Count2 and count will increment through each loop and so the comparison
			// will change each time.
			if (sentences[_root['count2']].charAt(0) == searchitems[_root['count']]) {
				// If a match is found then the particular sentence is added 
				// to the output box
				output += sentences[_root['count2']] + "\n";
			}
			// Now we increment count2 for our next loop
			count2++;
		}
		// Now we increment count for our next loop
		count++;
	}
	// This outputs count so you know that each item you entered has been searched for
	// when debugging.
	trace("Count=" +count);
}
</textarea>
Feel free to pick holes in my scripting, as I am self-taught.
Objects are: searchtext, input_t, output and the search button itself.
  #6 (permalink)  
Old Aug 22nd, 2003, 15:51
Anonymous User
Guest
Posts: n/a
Great solution. Have done something similar myself. I'll try and dig it up and post it here.
Closed Thread

Tags
search, text, file, first, char, word

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
search xml content for a specific word karloff PHP Forum 2 May 8th, 2008 18:46
Converting Word Document to PDF file. akshitshah Scripts and Online Services 5 Jan 8th, 2008 07:25
print file (pdf, jpeg or word doc) ecat JavaScript Forum 0 Sep 15th, 2006 18:28
Pasting Word Doc into Text Area Paula Web Page Design 6 Aug 25th, 2006 09:15
How make Word file same as html file in ASP humair Classic ASP 5 Sep 24th, 2003 14:35


All times are GMT. The time now is 04:22.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43