program DOSSTAMP {was GL_SMITH} { Shows/sets date-time stamp of a DOS file to any value in 1980-2107, including all Mo=0..15, Dy=0..31, Hr=0..31, Mn=0..63, Sc even 0..62} ; uses Dos ; function Q(X : integer) : longint ; var N : integer ; T : longint ; begin T := 0 ; if ParamStr(X)>'' then Val(ParamStr(X), T, N) ; Q := T end {Q} ; var S : string ; F : file ; Yr, Mo, Dy, Hr, Mn, Sc, LI : longint ; procedure WrYr ; begin Writeln(LI:14, ' =>', (LI shr 25) + 1980:6, (LI shr 21) and $0F:3, (LI shr 16) and $1F:3, ',', (LI shr 11) and $1F:3, (LI shr 05) and $3F:3, (LI shl 01) and $3F:3) ; end {WrYr} ; BEGIN Writeln(' DOSSTAMP www.merlyn.demon.co.uk >= 1998/11/15') ; if Copy(ParamStr(1), Length(ParamStr(1)), 1)='?' then begin Writeln(' Apply *any* timestamp to a DOS file :') ; Writeln(' prompt>DOSSTAMP [File [Yr [Mo [Dy [Hr [Mn [Sc]]]]]]]') ; Writeln(' if not (Yr in [1980-2107]) then timestamp is longint(Yr)') ; Writeln(' Ctrl-C to not change timestamp.') ; HALT end ; Write(' File ') ; if ParamStr(1)>'' then begin S := ParamStr(1) ; Write(S, #32) end else begin Write('? ') ; Readln(S) end ; Assign(F, S) ; {$I-} Reset(F) {$I+} ; if IOResult=2 then begin Write('- Create? ') ; S := 'n' ; Readln(S) ; if UpCase(S[1])<>'Y' then HALT ; Rewrite(F) ; Write(' Created ') end ; GetFTime(F, LI) ; WrYr ; if ParamCount<2 then begin Write(' Yr Mo Dy Hr Mn Sc ?????? (or ^C) ') ; Readln(Yr, Mo, Dy, Hr, Mn, Sc) end else begin Yr := Q(2) ; Mo := Q(3) ; Dy := Q(4) ; {} Hr := Q(5) ; Mn := Q(6) ; Sc := Q(7) end ; if (Yr<1980) or (Yr>2107) then LI := Yr else LI := (Yr-1980) shl 25 + Mo shl 21 + Dy shl 16 {} + Hr shl 11 + Mn shl 05 + Sc shr 01 ; WrYr ; SetFTime(F, LI) ; Close(F) ; END.