<pre>function EncodeSearch text, type  put empty into res  if type = "normal" then    repeat with x = 1 to the number of words in text      put word x of text into theWord      if first char of theWord = quote and last char of theWord = quote      then put "(" & theWord & ")+" & return after res      else put "(" & Quotify(FixItem(theWord)) & ")+" after res    end repeat    delete last char of res  else if type = "exact" then    put "(" & Quotify(text) & ")" & return into res  else if type = "boolean" or type = "strict boolean" then    -- ak    if type = "boolean" then put "" into func    else if type = "strict boolean" then put "*" into func        put "" into needToken    put 0 into level    repeat with x = 1 to the number of words in text      put word x of text into theWord      if first char of theword = "(" then        if needToken <> "" then          put "Error: Parenthetical subexpression not part of expression."          exit to HyperCard        end if        repeat while char 1 of theword = "("          add one to level          put "(" after res          delete char 1 of theword        end repeat      end if      if last char of theword = ")" then        put 0 into paren        repeat while last char of theWord = ")"          subtract one from level          if level < 0 then            put "Error: Closed an unopen parenthesis"            exit to HyperCard          end if          delete last char of theword          delete last char of needToken          add one to paren        end repeat        if (needToken&theWord)<>"" then          put func&"("&Quotify(FixFaker(needToken&theword,type)) & ")"          after res        end if        repeat paren          put ")" after res        end repeat        put "" into needToken        next repeat      end if      if theword = "and" or theword="or" then        if (RealLast(res) is in "and or not" or res="") and needToken="" then          put "Error: Misplaced and/or"          exit to HyperCard        end if        if needToken<>"" then          delete last char of needToken          put func&"("&Quotify(FixFaker(needToken,type)) & ")"          && theword &space after res        else          put space & theword & space after res        end if        put "" into needToken      else if theWord = "not" then        if needToken <> "" then          put "Error: NOT subexpression not part of expression."          exit to HyperCard        end if        put "not " after res      else        if first char of theWord = quote and last char of theWord = quote then          put the value of theWord into theWord        else if "(" is in theWord  or ")" is in theWord then          put "Error: Misplaced parenthesis"          exit to HyperCard        end if        if res <> "" and RealLast(res) is not in "not and or (" then          put "Error: Recognized conjunction must follow parenthetical          subexpression"          exit to HyperCard        end if        put theWord & space after needToken      end if    end repeat    if (needToken <> "") then      delete last char of needToken      put func&"("&Quotify(FixFaker(needToken,type)) & ")" after res    end if    if level > 0 then      put "Warning: Unclosed parenthesies closed."      repeat level        put ")" after res      end repeat    end if    get space & RealLast(res) & space    if it is in " not and or " then      put "Error: You forgot to finish typing."      exit to HyperCard    end if  end if  return resend EncodeSearch</pre>