Brian Stevens wrote: > I'm passing this fn a ptr to data and a string to find and it keeps > returning zero when the doc says either the offset into the pointer > or -1 should be returned. I can see both the data for the passed > pointer and the data for the search string while I'm stepping > through the code in the debugger, so it has the right data. My use > of the routine is slightly different from Staz's example because I > pass it a pointer, not a pointer from the dereferenced handle. > Since the formal parameter list for the fn expects a pointer my > thought was this should be ok. Any input on its use is welcome. I'd > post code but it might get unwieldy for the list. My call to the fn > looks like: > > local FN BlahBlah(note as str255,) > ....some other stuff here to find the correct array element > offset = 0 > ptrSize = fn GetPtrSize( gData.p(ele) ) > result = fn stazMunger ( gData.p(ele), offset , ptrSize , note ) > other stuff...... > > end fn > where note is defined as str255, offset and ptrSize are longs. > gData is a record where the "p" element (i.e. gData.p) is an array > of pointers (not handles). > 1. A returned offset of 0 means that the string occurred at the beginning of the text being searched. 2. stazMunger is buggy. Don't use it, unless you want incorrect results as in this example: dim as Str255 txt, searchFor txt = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa" txt = "Hello" searchFor = "" print fn stazMunger( @txt + 1, 0, 255, searchFor ) stop 3. Instead, use FindStringInText '--------------------- register on local dim as pointer txt, txtMax, target, txt2 // register vars dim as long findLength, firstChar, j // register vars local fn FindStringInText( txtStart as pointer, txtOffset as long, txtLength as long, findStr as Str255 ) '~'1 findLength = findStr // length of string long if ( findLength ) // null findStr is never found txtMax = txtStart + txtLength - findLength txt = txtStart + txtOffset firstChar = gFBLowerChar(findStr) // lower case first char for j = 2 to findLength findStr[j] = gFBLowerChar(findStr[j]) // make the rest lower case next while ( txt <= txtMax ) long if ( gFBLowerChar(txt.0``) == firstChar ) // check subsequent characters, if any target = @findStr + 1 // points to first char txt2 = txt j = findLength - 1 while ( j ) target++ txt2++ j-- if ( target.0`` != gFBLowerChar(txt2.0``) ) then exit if wend txtOffset = txt - txtStart : exit fn // found end if txt++ wend end if txtOffset = -1 // not found end fn = txtOffset '--------------------- Robert P.