Searching for multiple words in a document

Posted By: danohu

Searching for multiple words in a document - 12/31/13 13:34

Hi

I want to find multiple words in a text file e.g.

file_seek(filehandle,0,0);
xndex = file_find (filehandle, "gun");
xndexi = file_find (filehandle, "weapon");

but searching for one word at a time is inefficient in terms of the number of lines of code. It would be better to be able to search for multiple words e.g.
xndex = file_find (filehandle, "gun" "weapon" "enemy");

although this code does not work and is simply an illustration of what I am trying to achieve. I wondered if this is perhaps possible but:

1) my knowledge of what is possible with Lite-C is lacking?
2) searching for multiple words is possible in the commmercial edition of A8? (wishful thinking I imagine)
3) this is only possible with a DLL using e.g. python code, where one can search for multiple words in this manner including wildcards?

Thanks for your help. Happy 2014!
Posted By: Superku

Re: Searching for multiple words in a document - 12/31/13 13:42

I assume the text file is already given and not yet to be generated by one of your codes/ editors/ manually? Can't you just try to sort the text file more efficiently?
Posted By: FoxHound

Re: Searching for multiple words in a document - 01/01/14 04:02

Your best bet is to make a wrapper function, put in all the words you want, let the file find run through each individually and then sort them into an array or struct to be returned by the function.
© 2024 lite-C Forums