$! PAGEIT.COM $! $! This procedure reads a text file and breaks it into pages $! Optionally, the user can add a header line on each page. $! $! David Mathog, Biology Division, Caltech $! 23-JUL-1996 $! $! P1 is the name of the file to process $! P2 is the output file name. $! P3 is the print command $! P4 is the header line. It must include a to indicate the page $! number position $! P5 is the number of lines per page (default = 59) $! P6 is the range of PAGES to print (begin,end) $! $ if (P1 .eqs. "") $ then $ type sys$Input @pageit P1 P2 P3 P4 P5 P6 P1 is the name of the file to process P2 is the output filename P3 is the print command (specify either P2 or P3, not both) P4 is the header line, it must include a to indicate the position of the page number, the number of "X" indicate the number of spaces allowed P5 is the number of lines per page (default = 59) P6 is the range of pages to print, "begin,end", default is all $ exit $ else $ infile = P1 $ open/error=badinfile ifil: 'infile' $ endif $ if (P2 .eqs. "") $ then $ if(P3 .eqs. "") $ then $ write sys$output "PAGEIT:: fatal error, specify P2 OR P3" $ exit $ else $ now = f$time() $ username = f$getjpi("","USERNAME") $ username = f$edit(username,"COLLAPSE") $ tempname = "kill_" + username + "_" - + f$cvtime(now,,"MONTH") - + f$cvtime(now,,"DAY") - + f$cvtime(now,,"HOUR") - + f$cvtime(now,,"MINUTE") - + f$cvtime(now,,"HUNDREDTH") + ".txt $! $ open/write/error=badoutput ofil: 'tempname' $ omethod="PRINT" $ pcommand = P3 $ endif $ else $ if(P3 .eqs. "") $ then $ omethod = "FILE" $ open/write/error=badoutput ofil: 'P2' $ else $ write sys$output "PAGEIT:: fatal error, specify P2 OR P3" $ exit $ endif $ endif $! $ if (P4 .eqs. "") $ then $ header = "Page: !AS File:''infile'" $ spaces = 5 $ else $ scratch = P4 $ pagestart= f$locate("",scratch) $ spaces = pageend - pagestart $ header = f$extract(0,pagestart,scratch) + - "!AS" + - f$extract(pageend+2,f$length(scratch)-pageend,scratch) $ endif $ if (P5 .eqs. "") $ then $ apage = 59 $ else $ apage = P5 $ endif $! $ if (P6 .eqs. "") $ then $ first = 1 $ last = 2000000000 $ else $ temp = P6 $ first = f$element(0,",",temp) $ last = f$element(1,",",temp) $ if(first .gt. last) $ then $ write sys$output "PAGEIT:: page range specified is invalid" $ exit $ endif $ endif $! $! go ahead and process it $! $ pc = 1 $ count = 0 $ top: $ ostring = " " + f$string(pc) $ olen = f$length(ostring) $ ostring = f$extract(olen - spaces, spaces, ostring) $ if(pc .ge. first .and. pc .le. last)then write ofil: f$fao(header,ostring) $! $ count = count + 1 $ loop: $ read/end=done/error=done ifil: string $ count = count + 1 $ if (count .le. apage) $ then $ if(pc .ge. first .and. pc .le. last)then write ofil: string $ goto loop $ else $ if(pc .ge. first .and. pc .lt. last)then write ofil: string,f$fao("!^") $ if(pc .eq. last)then write ofil: string $ count = 0 $ pc = pc + 1 $ goto top $ endif $! $ done: $ close ifil: $ close ofil: $! $ if (omethod .eqs. "PRINT") $ then $ 'pcommand'/delete 'tempname' $ endif $! $ write sys$Output "PAGEIT: normal processing completed" $ exit $! $badoutput: $ write sys$output "PAGEIT:: fatal error, could not open output file" $ exit $badinfile: $ write sys$output "PAGEIT:: fatal error, could not open an input file" $ write sys$output "PAGEIT:: file = ''infile'" $ exit $!