$! $! The EACH command $! $! Usage: $! $ EACH specs ["(search)"] ["command"] ["initial"] ["final"] $! $ verify = 'f$verify(0)' $ on control_y then goto fin !Exit cleanly on CTRL/Y $ on warning then continue $ first = 1 !TRUE until first file seen $ if f$extract(0,1,p1) .eqs. "@" !File of specs? $ then assign/user_mode SYS$COMMAND SYS$INPUT !Could be from terminal $ copy/nolog 'f$parse(f$extract(1,99999,p1),".COM")' - SYS$SCRATCH:each_t_'f$env("DEPTH")'.tmp $ if .not. $STATUS then goto fin $ else direct := directory !Get the directory $ direct/brief/nohead/notrail/column:1 - /output=SYS$SCRATCH:each_t_'f$env("DEPTH")'.tmp 'p1' $! $! Add /versions:1 after /brief if you want the default to be one version. $! If you do that, you'll have to include /noversions on file specifications $! when you actually want all the versions include. $! $ if .not. $STATUS $ then $ write SYS$ERROR "?Can't get directory of ''p1'" $ goto fin $ endif $ endif $ search_arg = "" $ if f$extract(0,1,p2) .eqs. "(" !Search argument? $ then search_arg = f$extract(1,f$length(p2)-2,p2) !Save it $ p2 = p3 !Shift the rest over $ p3 = p4 $ p4 = p5 $ p5 = p6 $ p6 = p7 $ p7 = p8 $ p8 = "" $ endif $ if p2 .eqs "" $ then write SYS$OUTPUT "Enter commands to be executed, CTRL/Z when done:" $ copy/nolog SYS$COMMAND SYS$SCRATCH:each_c_'f$env("DEPTH")'.tmp $ p2 = "@SYS$SCRATCH:each_c_''f$env("DEPTH")'.tmp" $ endif $ open/read EACH_FILES SYS$SCRATCH:each_t_'f$env("DEPTH")'.tmp $ on control_y then goto ask $! $get_next_file: $ on warning then continue $ read/end=files_done EACH_FILES line $ if line .eqs. "" then goto get_next_file !Ignore blank lines $ compressed_line = f$edit(line,"COMPRESS") $ s = f$extract(0,f$locate(" ",compressed_line),compressed_line) $ if search_arg .nes. "" $ then assign/user _NL: SYS$ERROR !Supress "No strings $ assign/user _NL: SYS$OUTPUT ! matched message $ search/nooutput 's' 'search_arg' $ if $SEVERITY .ne. 1 then goto get_next_file $ endif $! $! We've got a matching file $! $ if first !Do this $ then first = 0 ! once only. $ if p3 .nes. "" $ then assign/user_mode SYS$COMMAND SYS$INPUT $ verify = f$verify(verify) $ 'p3' $Your_Command_Had_A_Trailing_Dash: verify = 'f$verify(0)' $! The label above will appear in the error message if the user's command $! had a trailing dash. $ on warning then continue $ deassign/user_mode/all $ endif $ endif $ n = f$parse(s,,,"NAME") $ t = f$parse(s,,,"TYPE") $ nt = n + t $ lv = s - f$parse(s,,,"VERSION") $ assign/user_mode SYS$COMMAND SYS$INPUT $ verify = f$verify(verify) $ 'p2' $Your_Command_Had_A_Trailing_Dash: verify = 'f$verify(0)' $ deassign/user_mode/all $ goto get_next_file $! $! Here on CTRL/Y while we are working through the file list $! $ask: $ inquire each_q "Type Y to continue with next file, N to exit now" $ if each_q then goto get_next_file $! else fall through. $! $! Here when there are no more files to process $! $files_done: $ if .not. first .and. p4 .nes. "" !Final present and files seen? $ then on warning then continue $ assign/user_mode SYS$COMMAND SYS$INPUT $ verify = f$verify(verify) $ 'p4' $Your_Command_Had_A_Trailing_Dash: verify = 'f$verify(0)' $ deassign/user_mode/all $ endif $! $! Here to clean up and exit $! $fin: $ on severe then continue $ close/nolog EACH_FILES $ if f$search("SYS$SCRATCH:each_%_''f$env("DEPTH")'.tmp;*") .nes. "" - then delete/nolog SYS$SCRATCH:each_%_'f$env("DEPTH")'.tmp; $ verify = f$verify(verify)