SeeView Manual

SeeView Statements and Script Symbols
HP NonStop SeeView Manual526355-004
9-42
FOR
This procedure uses a FOR statement to iterate through a cache, changing all
occurrences of #target to #newtext.
FOR rows DO BEGIN { For each row
LINE (row:=row+1)*h+1; { position to line.
FOR cols DO BEGIN { For each column
#tid:=#TRIM #list; { get next taskid
IF NOT #TASK #tid THEN
BEGIN { no task, create it
EXECUTE "TASK " & #tid;
END;
EXECUTE "WITH " & #tid;{ get "WITH taskid"
WINDOW #taskid CACHE LASTPAGE
SIZE w,h
EOFONLY NOCURSOR NOFRAME;
RIGHT:w; { move to next column
IF #list="" THEN #list:= #tasklist;
END;
END;
?SECT main
{---------}
TASK ci:=comint; { if not declared, proc declares
CALL
DrawWindowsOn("tacl ci pup cup scf cmi",3,2);
?PROC ChangeCache(Cacheid,#target,#newtext)
{-----------------------------------------}
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
, i { scratch integer var
, r { record no in cache
;
WITH Cacheid; { to use #taskcachelines
IF NOT #TASKCACHELINES THEN
RETURN; { nothing to scan for
FOR #TASKCACHELINES DO
BEGIN { read each line in cache
READ Cacheid CACHE (r:=r+1),#s;
SCAN #s UNTIL { search for target
#target->i;
IF i THEN { target found
BEGIN { figure text before/after
#before:="";{ text in #s before target
#after :="";{ text in #s after target
IF i>1 THEN { there is text before
#before:=#s[1:i-1];
IF (i+#SIZE #target) < (#SIZE #s) THEN
#after := #s[i+#SIZE #target:132];
#s:= #before & #newtext & #after;
{ #s updated, now update record in cache
WRITE Cacheid CACHE r UPDATE,#s;
END;
END;
Note. The preceding example is for demonstration purposes only to illustrate use of nested
FOR statements. This example performs a case-sensitive scan for the #target. The SEARCH
statement example shows a more efficient non-case-sensitive change mechanism.