!This program goes through the list of directories specified in LIST. !In each directory it looks at the file specified in FILE. !If the file exists and contains the string FIND (or an upper case !variant thereof), the file is left alone. !Otherwise, if it exists, the line ADD is added to the front of it, !otherwise the file is created and the line ADD is put in it. !Originally written to make sure all CS3 users had a LOGIN.COM file !containing a command to type out CS3:ALERT. !RWT 05/02/87 %begin %option "-nonstandard" %include "inc:util.imp" %string(255) - list = "cs3.dat", file = "login.com", add = "type cs3:alert", find = "cs3:alert" %routine do(%string(31)file) %string(255)line %integer pos,size %predicate already there %integer p=pos,n=size,k line = "" %cycle n = n-1 %falseif n<0 k = byte(p); p = p+1 %if k=nl %start %trueif line -> (find) line = "" %else k = k!32 line = line.tostring(k) %unless length(line)=255 %finish %repeat %end %routine kick off openoutput(1,file); selectoutput(1) printstring(add); newline %end %on 3 %start release selectoutput(0) printstring("Creating "; file); newline kick off closeoutput %return %finish mark connectfile(file,0,pos,size) selectoutput(0) %unless already there %start printstring("Adding to "; file); newline kick off %while size>0 %cycle size = size-1; printsymbol(byte(pos)); pos = pos+1 %repeat closeoutput %else printstring("Leaving "; file; " alone"); newline %finish release %end %string(7)directory %on 9 %start %stop %finish defineparam("List - for each directory listed in file",list,0) defineparam("File - look at this file",file,0) defineparam("Add - and add this to it",add,0) defineparam("Find - unless it contains this",find,0) processparameters("??") openinput(1,list) %cycle selectinput(1) read(directory) do(directory.":".file) %repeat %end