Path: utzoo!attcan!uunet!samsung!usc!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!rutgers!bellcore!flash!sdh From: sdh@flash.bellcore.com (Stephen D Hawley) Newsgroups: comp.sys.mac.programmer Subject: List Manager Strangeness Message-ID: <20392@bellcore.bellcore.com> Date: 27 Feb 90 19:40:06 GMT Sender: news@bellcore.bellcore.com Reply-To: sdh@flash.UUCP (Stephen D Hawley) Organization: Bellcore, Morristown, NJ Lines: 54 Hey - here's a question. I have a list that contains a list of available font names (built as per TN 191) and I want to find which font name matches a particular window's font. So I call LSearch() and it returns FALSE no matter what. So I do a break and stepp through and find out that yes, in fact, the font name I have is in the list. So I install my own comparison function. It never gets called (!!). Is this normal behavior? I'm now doing the following: ListHandle fontList; FindCurrentFont(win) WindowPtr win; { int fNum, i, dataLen; Str255 fName, cellName; Cell c; fNum = win->txFont; GetFontName(fNum, fName); /* This for() loop works --but the rom call (commented out below) doesn't. */ /* * c.h = c.v = 0; * if (!LSearch((Ptr)(fName+1), (int)(*((unsigned char*)fName)), * NIL, &c, fontList)) c.v = 0; */ c.h = 0; for (i=(**fontList).dataBounds.top; i<(**fontlist).dataBounds.bottom; i++) { c.v = i; /* get 1 more character than the length of the target name */ dataLen = (int)(*((unsigned char *)fName))+1; LGetCell((Ptr)(cellName+1), &dataLen, c, fontList); /* dataLen has the actual length now */ *cellName = (char)dataLen; if ((int)(*((unsigned char*)fName)) == dataLen && strncmp(fName+1, cellName+1, dataLen) == 0) break; } if (i >= (**fontList).dataBounds.bottom) c.v = 0; /* no match */ return(c.v); /* I actually do something else, but you get the idea */ } So what gives? Steve Hawley sdh@flash.bellcore.com A noun's a special kind of word. It's ev'ry name you ever heard. I find it quite interesting, A noun's a person place or thing.