[Coco] "C string searching question

Bill Pierce ooogalapasooo at aol.com
Tue Oct 2 00:37:29 EDT 2012


That sounds like adding insult to injury. Don't get me wrong, but you're talking about a "new" list being created every time I change directories. This is already being done as it is. The "records[xx].recname[yy}" contains only the characters of a songname. No extension. Since we're talking up to 33 chars per name times 500 possible names and the possibilty of them changing on the fly as the list is recreated each time a directory is accessed. And very fast too (for a Coco). To try and tokenize all the possibilties would be a task. Hence the need to just "search" the string for the occurance of the search string as it could occure anywhere in the string. i.e. to search for "dog", it could occure in "GiveTheDogABone" or in "dog-days" or in "working_like_a_dog". The song titles can contain any legal and printable OS9 character., so the occurance could fall anywhere in the string. Once the string is found, there will be a yes/no box to see if that's the right song. If yes, then it will go to there in the list. If no, then it will continue to search.
The whole idea is that if you only remember the song title has "girl" in the title (remeber? we ARE getting older), you could search and find every song with girl in the title. 

Bill P

Music from the Tandy/Radio Shack Color Computer 2 & 3
https://sites.google.com/site/dabarnstudio/
Bill Pierce
ooogalapasooo at aol.com




-----Original Message-----
From: Steve <6809er at srbsoftware.com>
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Sent: Tue, Oct 2, 2012 12:12 am
Subject: Re: [Coco] "C string searching question


Maybe you should try a tokenizing search?  Start with creating a list of 
tokens for all the "words" in the song titles. (This table is updated 
only when a new song is added to the database.)  Don't forget to save 
the title as a list of tokens too.

When a user give you titles to search for,  you need to convert it into 
a token list based on the token database of all the song titles.  Any 
search words not in the token list should be dropped.

Now do a token list to token list search.  (Comparing the shorter token 
list is a lot faster then doing a string search over and over.)

Oh, don't forget to change the letters to the same case and convert any 
non-alphanumeric to spaces before tokenizing.

You will find this type of search is much faster and easier since most 
of the work is done when creating the token database.


On 10/1/2012 8:15 PM, Bill Pierce wrote:
> Here's a "C" programming question for you "C" gurus out there
>
> I'm writing a search routine for SoundChaser's 500 song database.
> here's the data format:
>
> #define NRECORDS 500   /* max num of records */
> #define RECNAMEL  33    /* size of record name */
>
> typedef struct{
>     char recname[RECNAMEL];   /* song name */
>     char ext[4];    /* filename extension */
>     int typ;     /* song type (midi mus ect ) */
>     int order;   /* selection order */
>     bool played   /* has played flag */
> } Record;
>
>
> direct short nrecords;  /* actual number of records */
> Record records[ ];   /* the record keeper */
> char srchstr[10];  /* the search string
>
> ok, here's the loop:
>
> loop to input srchstr[xx] here
>
> for(cnt=0; cnt<=nrecords; cnt++) {
>     for(xx=0; xx<=sizeof(srchstr); xx++){
>        if(srchstr[xx] == records[cnt].recname[xx]) {
>            search some stuff here..
>            then search some more stuff
>        }
>     }
> }
>
> what should I do in the loop or is there a better looping routine I can use to 
find the matching string.
> The record will be searched for the matching sting anywhere in the record i.e.   
search for rock;  likearock; rocknroll; iluvrocknroll;
> what would be the best way to do this efficiantly?
> the result has to point to cnt as that will be the index to the record found.
>
> any ideas? (I just love cans of worms)
> Bill P
> Music from the Tandy/Radio Shack Color Computer 2 & 3
>
> https://sites.google.com/site/dabarnstudio/
> Bill Pierce
> ooogalapasooo at aol.com
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco


--
Coco mailing list
Coco at maltedmedia.com
http://five.pairlist.net/mailman/listinfo/coco

 



More information about the Coco mailing list