From:	CSBVAX::MRGATE!@KL.SRI.COM:info-vax-request@kl.sri.com@SMTP 24-NOV-1987 08:55
To:	EVERHART
Subj:	Re: Lost features in "newer, better" operating systems

Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Mon 23 Nov 87 19:59:58-PST
Received: by ucbvax.Berkeley.EDU (5.58/1.26)
	id AA14545; Mon, 23 Nov 87 18:47:40 PST
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 23 Nov 87 00:50:29 GMT
From: munnari!murdu!u3369429@uunet.uu.net  (Michael Bednarek)
Organization: I.A.E.S.R., Melbourne University
Subject: Re: Lost features in "newer, better" operating systems
Message-Id: <1326@murdu.OZ>
References: <8711130234.AA12248@ucbvax.Berkeley.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <8711130234.AA12248@ucbvax.Berkeley.EDU> "ERI::SMITH" <smith%eri.decnet@mghccc.harvard.edu> writes:
>My pet beef is the inability to get a DIR in any sorting order other than
>alphabetical (e.g. reverse chronological).  The Macintosh has done it for
>three years; RT-11 has done it for at least, oh hell, ages and ages.  Why
>can't VMS do it?  

Well, just because there is no genuine TDIRECTORY under VMS doesn't mean
you can't do it. Here is my procedure TDIR.COM which does it (at a price):

Michael Bednarek		
Institute of Applied Economic and Social Research (IAESR)
Melbourne University, Parkville 3052, AUSTRALIA, Phone : +61 3 344 5744
Domain: u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au}  or  mb@munnari.oz.au
"bang": ...UUNET.UU.NET!munnari!{murdu.oz | ucsvc.dn.mu.oz}!u3369429

"POST NO BILLS."

....................... Cut between dotted lines and save ......................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.03 07-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by U3369429 (Michael Bednarek)
$! on Monday 23-NOV-1987 11:42:34.53
$!
$! It contains the following 1 file:
$! TDIR.COM
$!=============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="TDIR.COM"
$ Check_Sum_is=1389475295
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X$ Verify='F$Verify(F$TRNLNM("COMMAND_DEBUG"))
X$ If .not.F$Verify() then On Control_Y then Goto Exit2
X$ Ask="Inquire/NoPunctuation"
X$ P1=F$Edit(P1,"Compress,Trim,UpCase,UnComment")
X$ If P1.eqs."" then goto Start
X$ If P1.nes."?".and.P1.nes.F$Extract(0,F$Length(P1),"/HELP") then goto Start
X$ Type SYS$Input
X
X Procedure: TDIR.COM Version 2.10 `169 Michael Bednarek, 1986
X
X This procedure tries to emulate the TOPS20 command TDIRECTORY,
X producing a directory list sorted by date.
X
X Usage: $ TDIR [file,...qualifier,...]
X Example: $ TDIR *.DAT,*.EXE/SIZE=ALL/OWNER *.FOR
X Installation: $ TD*IR:=="@TDIR """
X
X This is a very expensive procedure.
X It uses about 5 to 10 times more CPU than an equivalent DIRECTORY command.
X Three workfiles are used:
X`009$-TEMPTD.-TMP0`009Output of DIRECTORY/DATE/selective.qualifiers
X`009$-TEMPTD.-TMP1`009File names cum dates in position [128,16]
X`009$-TEMPTD.-TMP2`009Same, sorted by [128,16]
X
X The specific function of TD is controlled by additional qualifiers:
X /ASCENDING or /DESCENDING, /TDATE={CREATED,MODIFIED,BACKUP}
X
X /ASCENDING or /DESCENDING specify in which order the files should be sorted.
X
X /TDATE={CREATED,MODIFIED,BACKUP} specifies which date should be used.
X$ Ask nf "More? "
X$ If .not.nf then goto Exit2
X$ Type SYS$Input
X
X The default values for these qualifiers are:
X /DESCENDING/TDATE=CREATED
X
X$ Goto Exit2
X$!
X$Start:
X$ Say="Write SYS$Output"
X$ This_Directory=F$Environment("Default")
X$ Qual=""
X$ SQual=""
X$ Which_Date="/Date=Created"
X$ Sort_it="Descending"
X$ WorkFile="SYS$LOGIN:$-TEMPTD.-TMP"
X$ file1=""
X$ If F$Search("''WorkFile'%").nes."" then Delete 'WorkFile'%;*
X$!
X$! Parsing the command line.
X$! Dissect the command line lumps separated by blanks
X$ nf=0`009! number of FILE arguments
X$ na=-1
X$nextA:
X$ na=na+1
X$ a=F$Element(na," ",P1)`009! next lump
X$ If a.eqs." " then goto No_more
X$Check_Slash:
X$ If F$Extract(0,1,a).eqs."/" then goto Do_Q`009! Is it a qualifier?
X$ nf=nf+1`009`009`009`009`009! No. So it must be a file
X$ Spos=F$Locate("/",a)`009`009`009`009! Possible position of a "/"
X$ Kpos=F$Locate(",",a)`009`009`009`009! Possible position of a ","
X$ z=Kpos`009`009`009`009`009! z now points to the next
X$ If Spos.lt.z then z=Spos`009`009`009! separator, either "/" or ","
X$ aSlash=z.ne.Spos`009`009`009`009! Skip a ",", don't skip "/"
X$ file'nf=F$Extract(0,z,a)`009`009`009! Finally, the file argument
X$ If file'nf.eqs.a then goto nextA`009`009! Was that all?
X$ a=F$Extract(z+aSlash,255,a)`009`009`009! No. Reduce 'a' ...
X$ Goto Check_Slash`009`009`009`009! ... and loop.
X$!
X$Do_Q:`009`009! Process qualifiers
X$ nq=0
X$Next_Q:
X$ nq=nq+1
X$ Q=F$Element(nq,"/",a)
X$ If Q.eqs."/" then goto nextA
X$!`009`009`009Check for selective qualifiers
X$ l=F$Locate("=",q)
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"BEFORE")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"BY_OWNER")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"EXCLUDE")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"SELECT")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"SINCE")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"BACKUP")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"CREATED")`009then goto SQual
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"MODIFIED")`009then goto SQual
X$!`009`009`009Check for non-sensical qualifiers
X$ If Q.eqs.F$Extract(0,l,"GRAND_TOTAL") then goto Bad_Qual
X$ If Q.eqs.F$Extract(0,l,"TOTAL")`009then goto Bad_Qual
X$!`009`009`009Check for TD-specific qualifiers
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"ASCENDING")`009then goto Ascend
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"DESCENDING")`009then goto Descend
X$ If F$Extract(0,l,Q).eqs.F$Extract(0,l,"TDATE")`009then goto TDate
X$!
X$ qual=qual+"/"+Q
X$ Goto Next_Q
X$!
X$Ascend:
X$ Sort_it="Ascending"
X$ Goto Next_Q
X$!
X$Descend:
X$ Sort_it="Descending"
X$ Goto Next_Q
X$!
X$TDate:
X$ Which_Date="/"+F$Extract(1,F$Length(Q),Q)
X$ Goto Next_Q
X$!
X$Bad_Qual:
X$ Say "%-TDIR-I-BADQUAL  Non-sensical qualifier ''Q' ignored"
X$ Goto Next_Q
X$!
X$SQual:
X$ SQual=SQual+"/"+Q
X$ Goto Next_Q
X$!
X$No_More:
X$ Say "%-TDIR-I-COLLECTNAMES  Collecting file names"
X$ Files=File1`009`009`009`009! First file argument
X$ na=1
X$Next_File:
X$ If na.ge.nf then goto Files_Done
X$ na=na+1`009`009`009`009! Remaining file arguments, ...
X$ Files=Files+","+File'na`009`009! ... separated by commas
X$ Goto Next_File
X$!
X$Files_Done:
X$! Display=Filename*128 + Fill*2 + Date*17 = 147
X$ Directory/Output='WorkFile'0'/NoHeader/NoTrailer'Which_Date -
X`009/Width=(Display=147,Filename=128)'SQual 'Files
X$!
X$ Say "%-TDIR-I-GETDATE Get file dates"
X$ nf=0
X$ Open/Read Input 'WorkFile'0
X$ Read/End_of_File=No_Dir Input x
X$ Open/Write WorkFile 'WorkFile'1
X$Next0:
X$!`009`009`009Skip this procedure's workfiles
X$ If F$Locate("''WorkFile'",x).ne.F$Length(x) then goto Next
X$ File_Date=F$CVTime(F$Extract(130,17,x))
X$ x=F$Extract(0,128,x)
X$! Device and Directory specifications have to be stripped from the file name,
X$! otherwise DIRECTORY produces weird lists.
X$ If F$Parse(x,,,"Device","Syntax_Only") -
X    +F$Parse(x,,,"Directory","Syntax_Only").eqs.This_Directory then -
X`009goto Add_Time
X$!NewDir:
V$! The reason this procedure works only in the current default directory is th
Xe
X$! odd behaviour of DIRECTORY with arguments like
X$! DIR D_3:[FRED]A.A,D_3:[FRED]C.D
X$ Say "%-TDIR-W-NOTACROSSDIR  TD doesn't work across directories."
X$ Say "%-TDIR-W-OMITFILE  ",x
X$ Goto Next
X$Add_Time:
X  x=F$Parse(x,,,"Name","Syntax_Only")+F$Parse(x,,,"Type","Syntax_Only") -
X   +F$Parse(x,,,"Version","Syntax_Only")
X$ x[128,16]:="''File_Date'"
X$ Write WorkFile x
X$ nf=nf+1
X$!
X$Next:
X$ Read/End_of_File=Done Input x
X$ Goto Next0
X$!
X$No_Dir:
X$ Close Input
X$ Goto Exit
X$Done:
X$ Close Input
X$ Close WorkFile
X$!
X$ Say "%-TDIR-I-SORT  Sorting (''Sort_it') dates for ''nf' files"
X$ Sort/Key=(Position:129,Size:16,'Sort_it')/Key=(Position:1,Size=128) -
X`009'WorkFile'1 'Workfile'2
X$!
X$! Read records from the sorted file and insert a DIRECTORY command every
X$! 1023 characters.
X$! Find length of command (+11 is for ``DIRECTORY`` plus `` -``):
X$ lc=F$Length("''Which_Date'''Qual'")+11
X$ Open/Read Input 'WorkFile'2`009`009`009! The sorted file
X$ Read/End_of_File=noFile Input x`009`009! Anything there?
X$ Files=F$Element(0," ",x)
X$ Cont=""
X$ On Warning then goto Debug
X$Read_Sort0:
X$ lf=F$Length(Files)
X$Read_Sort:
X$ Read/End_of_File=EOF Input x`009`009`009! Read record n
X$ x=","+F$Element(0," ",x)
X$ lx=F$Length(x)
X$ If lc+lf+lx.ge.1023 then goto Dir
X$ Files=Files+x
X$ lf=lf+lx
X$ Goto Read_Sort
X$Dir:
X$ If Cont.nes."" then 'Cont
X$ Directory'Which_date''Qual' -`009`009`009! ... another DIRECTORY
X  'Files
X$ Files=F$Extract(1,lx-1,x)
X$ Cont=Say+" "" (continued)"""
X$ Goto Read_Sort0
X$Debug:
X$ Say "%-TDIR-F-DEBUG  Debug information from procedure TDIR:"
X$ Show Symbol files
X$ Show Symbol lf
X$ Show Symbol lc
X$ Stop
X$!
X$noFile:
X$ Close Input
X$ Goto Exit
X$!
X$EOF:
X$ Close Input
X$ If Cont.nes."" then 'Cont
X$ Directory'Which_date''Qual' -`009`009`009! Write the last command
X  'Files
X$!
X$Exit:
X$ If .not.F$TRNLNM("COMMAND_DEBUG") then Delete 'WorkFile'%;*
X$Exit2:
X$ If F$TRNLNM("WorkFile").nes."" then Close WorkFile
X$ If F$TRNLNM("Input").nes."" then Close Input
X$ Verify=F$Verify(Verify)
$ GoSub Convert_File
$ Exit
