PARM cmdstr entry=main # Script scans the redo stack, from top-of-stack (TOS), backwards towards the # begining, searching for the 1st command line that contains "cmdstr" anywhere. # All commands that are the name as this script are ignored. # Motivated by Ray Shahan. # if '!entry' = 'main' then if hpredosize = 0 then echo You do not have a REDO stack, please set HPREDOSIZE to a value echo greater than zero. return endif if not hpinteractive then echo You are an not interactive with this script. return endif listredo ;unn >lrtmp # create variables for each command line in the redo stack xeq !hpfile "!cmdstr" entry='listredo' "" do setvar _rdo_line edit(_rdo_line,_rdo_edit) echo !_rdo_line setvar _rdo_edit input() endwhile if _rdo_line <> "" then # execute the command continue !_rdo_line endif endif deletevar _rdo_@ return elseif '!entry' = 'listredo' then # Fill variable "array" so redo stack can be searced from TOS down. # Input comes from output of LISTREDO ;unn command. # Skip TOS redo line since it invoked this script! # setvar _rdo_x 0 setvar _rdo_size finfo(hpstdin,'eof')-1 while setvar(_rdo_x,_rdo_x+1) <= _rdo_size do setvar _rdo_!_rdo_x input() endwhile return elseif '!entry' = 'match' then # Find redo entry (now in variable "array") that matches user's string. # Search from last array element down to the first. Skip entries that match # the name of this script. Return _rdo_line as "" for no match, or the # matching cmd line. # setvar _rdo_txt dwns("!cmdstr") setvar _rdo_me dwns(basename(hpfile)) setvar _rdo_x _rdo_size+1 while setvar(_rdo_x,_rdo_x-1) > 0 and & (pos(_rdo_txt,dwns(_rdo_![_rdo_x-1])) = 0 or & dwns(word(_rdo_![_rdo_x-1])) = _rdo_me) do endwhile if _rdo_x > 0 then # match setvar _rdo_line _rdo_!_rdo_x else setvar _rdo_line "" endif return endif