The Daily Click ::. Forums ::. Klik Coding Help ::. Check if a word exists.
 

Post Reply  Post Oekaki 
 

Posted By Message

Ando



Registered
  08/04/2006
Points
  100
30th December, 2006 at 20:30:21 -

Hey, all. I got Multimedia Fusion 2 Developer. Many happies. ANYWAY...
So, I made an INI database of a bunch of Japanese words, and I'm trying to figure out how to do the following:
1) User types word(s) into edit box, clicks "Send" or something like that activating the next step.
2) Computer checks through INI file to verify that the words exist.
3) If a word is found that does not exist, write it to the INI file.

Okay, I figured it out. Now I've realized that I need it to check each individual word. Is that possible? For instance, if I type, "I like pie", can it check "I", "like" and "pie" separately?

In case it matters, each word in the database is in its own group.

Image Edited by the Author.

Image Edited by the Author.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
30th December, 2006 at 20:38:30 -

If the groups names are numbered in some sort of coherent order, you could check against GroupItem$("Ini", "Groupname" + Str$(value of some counter), "ItemName") continually and compare this to the entered word (the GetText$() of the Edit box), incrementing the counter each time until the group is not found.

 
http://www.davidn.co.nr - Games, music, living in America

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
30th December, 2006 at 23:21:46 -

It's 22:34 right now, so I can't give you a good answer, but a couple tricks with wildcards and some negative events should do the trick.

 
n/a

Dannyman



Registered
  07/04/2006
Points
  6
31st December, 2006 at 01:05:04 -

hoohoohoo, maybe der is some way to store it all as a big-ass string, then u can load it up and split it with some string functions like in VB then you could jus loop thru the array indexes... or if you really couldn't do that maybe embed a php page, program yer skript in php because it can manage strings and such, then just serialize the string and store its contents to an ini file. The possibilities are endless man!

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
31st December, 2006 at 02:58:49 -

The way I'd probably do it is using String Parser to get each individual word (use a space as delimeter). Then my INI file would look something like this:

Cheese=1
Sausage=2
Ham=3
Pork=4

And so on - the numbers aren't needed, would just be there to return some kind of value. Then in the loop, you just set to retrieve the value of the items "Cheese" and "Ham" or whatever, and if you get a return value - then the word exists. And you don't get a return value, then the word doesn't exist. I'll try making an example file - I've no idea if this method works at all

Edit: Made an example file. I have tested it and I think it works - take a look anyway!

http://www.ectoprods.com/flava/dictionary.zip

In this case, if the word doesn't exist then a string is set to tell you it doesn't exist. In your case, you'd just add the word to the INI or do whatever you want.

Image Edited by the Author.

 
This is a signature. Have this one on me.

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
31st December, 2006 at 03:36:33 -

You know, I have to call Flava's method absolute genius - it seems completely backwards at first glance, but makes things a lot simpler. I'm impressed!

 
http://www.davidn.co.nr - Games, music, living in America

Werbad



Registered
  18/09/2002
Points
  235
31st December, 2006 at 10:07:32 -

That example only works if the invalid word is in the end...

And i dont see the point in using an INI that way...

I wrote some own code using your example as base:

* Start of Frame
- String Parser: Add delimiter " "

* Button "Check Words" clicked
- String Parser: Set Source string to Edittext$("Sentence")
- Sentence: Set string to ""
- Start loop "checkword" listCount("String Parser") times

* On loop "checkword"
+ FindStringExact("Dictionary", listGetAt$("String Parser", LoopIndex("checkword")+1), 0) = -1
- Sentence: Set string to "NON-EXISTANT WORD EXISTS"

Instead of changing the string, you can add the word to the List Object

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
31st December, 2006 at 11:13:59 -

Yeh my example file is a bit broke - but you get the idea. I kind of rushed the loops and stuff, but if you get them right then I'm sure the method would work.

Image Edited by the Author.

 
This is a signature. Have this one on me.

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
31st December, 2006 at 12:09:47 -

String Parser does lag up the application abit when it's filled up.. Or is it just me?

Edit: Although I did fill it up with 300,000 elements.

Image Edited by the Author.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.
   

Post Reply



 



Advertisement

Worth A Click