#!/usr/bin/mumps # Sept 16, 2017 # Copyright 2017 Kevin C. O'Kane if '$data(%1) write "parameter missing",! halt open 1:"../osu.medline,old" if '$test write "file not found",! halt use 1 kill ^MH set x=0 // a counter to limit the size set i=$ztell // return the integer offset in the file for use 1 read a quit:'$test!(x>%1) do # if a blank line, record the offset - this is the start of an abstract . if a="" set i=$ztell set x=x+1 quit // return the offset in the file . if $extract(a,1,3)="MH " do .. set a=$zlower($piece($extract(a,7,255),"/",1)) # create or increment entry for word .. if $data(^MH(a)) set ^MH(a)=^MH(a)+1 .. else set ^MH(a)=1 # store the offset .. set ^MH(a,i)="" # write for each heading the titles associated with it use 5 set x="" for set x=$order(^MH(x)) quit:x="" do . write x," occurs in ",^MH(x)," documents",! . for off=$order(^MH(x,off)) do .. use 1 .. do $zseek(off) .. for read a if $extract(a,1,3)="TI " do quit ... use 5 ... write ?5,off,?15,$extract(a,7,80),!