-- Display user dialog to get the search text local dialog = finenv.UserValueInput() dialog.Title = "Enter Search String" dialog:SetTypes("String") dialog:SetDescriptions("Text expression search string") local results = dialog:Execute() if not results then return end if results[1] == "" then return end -- Load all the text expression defs local exprdefs = finale.FCTextExpressionDefs() exprdefs:LoadAll() -- Init a table for all the found expressions local foundexpressions = {} -- Search all text expression defs for exprdef in each(exprdefs) do local exprstring = exprdef:CreateTextString() exprstring:TrimEnigmaTags() if exprstring:ContainsLuaString(results[1]) then -- Add matching text expression def to table table.insert(foundexpressions, exprdef) end end -- Display Finale's expression selection dialog box -- for each found expression. -- Continue if the user cancels the dialog box. for k, v in pairs(foundexpressions) do if finenv.UI():DisplayTextExpressionDialog(v.ItemNo) ~= 0 then -- User confirmed the dialog - exit return end end