news |
info |
people |
software |
stuff |
This routine works like Hypercard's built-in Offset function, except that it returns the line number where the key was found, instead of the character number.
function UL_LineOffset key,text -- get the offset of the key in characters get offset(key,text) if it is 0 then -- the key isn't present, so return zero as the result return 0 else -- delete everything after the first character of the key delete char it+1 to length(text) of text -- replace what was the first character of the key with -- something that definitely isn't a return character put "x" into last char of text -- return the number of lines in what's left of the text -- since the last line of the text now contains the key, -- this value gives us the line number where the key was found return the number of lines in text end if end UL_LineOffset