Updated version of ARCLAST, now with comments (!) plus detection of ASCII-ified
VMARCs and non-VMARCs. To test: ARCLAST PROFILE EXEC or XEDIT a VMARC, issue:
set hex on
c/:CFF/x'3a434646'/*
file bad
Then issue ARCLAST BAD
...phsiii
---------
/* ARCLAST EXEC -- List last-updated file in a VMARC, or all files */
address command
all = '| take first 1' /* By default, only show last file */
arg fn ft fm . '(' options ')' /* Parse command line */
if abbrev('?', fn) then signal Help /* No parms/wants help */
do while options <> '' /* Parse options */
parse var options option options /* Get an option */
select
when option = 'ALL' then all = '' /* If ALL, kill filter */
otherwise
say 'Invalid option "'option'"'
exit 24
end
end
if ft = '' then ft = 'VMARC' /* Default filetype */
if fm = '' then fm = '*' /* Default filemode */
'PIPE (name ArcLast endchar ?)' , /* Get fileids/timestamps */
'| <' fn ft fm , /* Read the VMARC */
'| rest: strfind /:CFF/' , /* Get file headers */
'| specs 11.18 1 31-33 20' , /* Just keep fileids & timestamps */
'| specs 1.8 1 9.8 10' , /* Reformat timestamps */
' 20.1 c2x 22 @/@ 24 21.1 c2x 25 @/@ 27 22.1 c2x 28' ,
'| nineties: locate 22 /0/' , /* Send 19xx away */
'| specs 1-18 1 /20/ 20 22-* n' , /* Add 20 for 20xx files */
'| rejoin: faninany' , /* 19xx files come back in */
'| sort 20-25 d' , /* Sort, newest first */
all , /* Just keep most recent, maybe */
'| console' , /* And display the file(s) */
'| count lines' , /* See whether we found any */
'| var count' , /* And remember that */
'?' ,
'rest:' , /* Non-file header lines come here */
'| strfind x3A434646' , /* Look for ASCII version */
'| count lines' , /* See if there were any */
'| var ascii' , /* And remember if so */
'?' ,
'nineties:' , /* 19xx files come here */
'| specs 1-18 1 /19/ 20 22-* n' , /* Add century */
'| rejoin:' /* And go rejoin 20xx files */
if count = 0 then do
if ascii > 0 then
say 'File appears to have been translated to ASCII and thus' ,
'destroyed.'
else say 'Not a VMARC file.'
end
exit
Help:
say 'ARCLAST lists the most recent file in a VMARC (or, optionally,'
say 'all files in a VMARC, sorted with most recent files first).'
say ''
say 'Format is:'
say ''
say 'ARCLAST fn <ft <fm>> <( <ALL> <)> >'
say ''
say 'where "fn ft fm" is the fileid of a VMARC file; "ft fm"'
say 'default to "VMARC *".'
say ''
say 'The ALL option lists all files, not just the most recent.'
say ''
say 'Comments/complaints/suggestions/cash to [EMAIL PROTECTED]'