SeeView Manual

SeeView Statements and Script Symbols
HP NonStop SeeView Manual526355-004
9-96
SEARCH
STARTING -1, -2, -3, ..., corresponds to the last, second from last, or third from last
line in cache.
STARTING column values are one relative. When a column points exactly to a
target in cache, the next target is found.
If you do not specify a STARTING option, the default is STARTING 0,0.
Examples
This example shows the SEARCH statement.
This procedure uses a SEARCH statement to search through a cache, changing all
occurrences of #target to #newtext. (The search is not case-sensitive.)
?MENU myData
line 1 {cache index 0
line 2 {cache index 1
line 3 {cache index 2
?SECT Main
VAR L {cache line index
, C {cache column number
, #s :=
"2"; {target
;
SEARCH MyData CACHE #s -> L,C; { L and C will be L=1, C=6
?PROC ChangeCache(Cacheid,#target,#newtext)
{-----------------------------------------}
{ Change all #target to #newtext for "Cacheid".
{ Note that the cache search is NOT case sensitive.
{-------------------------------------------------}
PARM Cacheid { taskid of cache to scan
,#target { target text to change
,#newtext { text to replace target
;
VAR #s { scratch string var
,#before { text before target
,#after { text after target
, r:=0 { record no in cache
, c:=0 { column no in cache
;
DO BEGIN { Loop while target found
SEARCH Cacheid CACHE #Target
STARTING r,c -> r,c
LINEFOUND #s;
IF r<0 THEN RETURN; { Target not found, done.
#before:=""; { text in #s before target
#after :=""; { text in #s after target
IF c>1 THEN { there is text before
#before:=#s[1:c-1];
IF (c+#SIZE #target) < (#SIZE #s) THEN
#after := #s[c+#SIZE #target:132];
#s:= #before & #newtext & #after;
{ #s updated, now update record in cache
WRITE Cacheid CACHE r UPDATE,#s;
c:= c + #size #newtext;
END UNTIL r<0;