<pre>function caseSensOffset pattern,str  put 0 into offs  repeat until str = empty    add 1 to offs    if charToNum( char 1 of str ) = charToNum( char 1 of pattern ) then      put length( pattern ) into len      put "true" into fullMatch      repeat with x = 2 to len        if charToNum( char x of str ) <> charToNum( char x of pattern ) then put false into fullMatch      end repeat      if fullMatch = true then return offs    end if    delete char 1 of str  end repeat  return 0end caseSensOffsetfunction caseSensOffset ch,inTxt  put false into foundSomething  put 0 into relOffset  put length(ch) into chLen -- keep us from repeating this inside loop  repeat until foundSomething    put offset(ch,inTxt) into thePos    if thePos = 0 then -- no match      put true into foundSomething      put 0 into returnOffset    else -- we have a match, now check case      put char thePos to thePos +chLen -1 of inTxt into foundTxt      if foundTxt > ch or foundTxt < ch then -- case mismatch :-(        delete char 1 to thePos of inTxt        -- above, we don't delete "1 to thePos +chLen -1" or else        -- we would get wrong results when, e.g. ch = "AA" and inTxt = "aAA"        add thePos to relOffset      else -- case matches        put true into foundSomething        put thePos +relOffset into returnOffset      end if    end if  end repeat  return returnOffsetend caseSensOffset</pre>