home *** CD-ROM | disk | FTP | other *** search
- '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- '* *
- '* SETFTD.BAS *
- '* *
- '* A File Date/Time Editor *
- '* written with Microsoft QuickBASIC v4.00b *
- '* *
- '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- '* *
- '* NOTE: *
- '* *
- '* THIS PROGRAM, ITS USE, OPERATION, AND SUPPORT IS PROVIDED "AS IS" *
- '* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, *
- '* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND *
- '* FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY *
- '* AND PERFORMANCE OF THIS PROGRAM IS WITH THE USER. IN NO EVENT SHALL *
- '* MICROSOFT BE LIABLE FOR DAMAGES INCLUDING, WITHOUT LIMITATION, ANY *
- '* LOST PROFITS, LOST SAVINGS, OR OTHER INCIDENTAL OR CONSEQUENTIAL *
- '* DAMAGES ARISING FROM THE USE OR INABILITY TO USE THIS PROGRAM, EVEN *
- '* IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILTY OF SUCH DAMAGES, OR *
- '* FOR ANY CLAIM BY ANY OTHER PARTY. *
- '* *
- '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- '
- ' This program must be used with QB4DIR.BAS inside QB.EXE, and LINKed to it
- ' outside.
- '
- '----------------------------------------------------------------------------
-
- DEFINT A-Z
-
- '----------------------------------------------------------------------------
-
- TYPE Register
- ax AS INTEGER
- bx AS INTEGER
- cx AS INTEGER
- dx AS INTEGER
- bp AS INTEGER
- si AS INTEGER
- di AS INTEGER
- flags AS INTEGER
- ds AS INTEGER
- es AS INTEGER
- END TYPE
-
- '----------------------------------------------------------------------------
-
- DECLARE FUNCTION CDate (m%, d%, y%)
- DECLARE FUNCTION CTime (h%, m%, s%)
- DECLARE FUNCTION FileHandle% (File$)
- DECLARE FUNCTION GetDrive$ ()
-
- ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- DECLARE SUB CloseHandle (Handle%)
- DECLARE SUB CoPrint (f%, b%, m$)
- DECLARE SUB DIR (Path$, DirArray() AS STRING, FA%)
- DECLARE SUB Interrupt (intnum AS INTEGER, inreg AS Register, outreg AS Register)
- DECLARE SUB InterruptX (intnum AS INTEGER, inreg AS Register, outreg AS Register)
- DECLARE SUB ParseCommandLine (Drive$, FileSpec$, NewTime$, NewDate$)
- DECLARE SUB Usage ()
-
- '----------------------------------------------------------------------------
-
- DIM regs AS Register
- DIM FileArray(255) AS STRING
- DIM dd AS LONG, tt AS LONG
-
- '----------------------------------------------------------------------------
-
- CoPrint 5, 0, "SETFTD.EXE changes the date and time of filespec."
-
- '----------------------------------------------------------------------------
-
- ParseCommandLine Drive$, FileSpec$, NewTime$, NewDate$
-
- '----------------------------------------------------------------------------
-
- DIR FileSpec$, FileArray(), 0
-
- '----------------------------------------------------------------------------
-
- 'BEGIN
-
- i = 1
-
- h = VAL(LEFT$(NewTime$, 2)) '
- m = VAL(MID$(NewTime$, 4, 2)) 'Parse NewTime$ into hh:mm:ss
- s = VAL(RIGHT$(NewTime$, 2)) '
-
- t = CTime(h, m, s) 'Convert it to two bytes
-
- m = VAL(LEFT$(NewDate$, 2)) '
- d = VAL(MID$(NewDate$, 4, 2)) 'Parse NewDate$ into mm/dd/yy
- y = VAL(RIGHT$(NewDate$, 4)) - 1980 '
-
- d = CDate(m, d, y) 'Convert in to two bytes
-
- WHILE INSTR(FileArray(i), " ") > 1
-
- Handle = FileHandle%(Drive$ + LEFT$(FileArray(i), INSTR(FileArray(i), " ")))
-
- IF Handle > 0 THEN
- regs.ax = &H5701
- regs.bx = Handle
- regs.cx = t
- regs.dx = d
-
- Interrupt &H21, regs, regs
-
- IF (regs.flags AND 1) = 1 THEN PRINT ">> "; regs.ax
-
- CloseHandle Handle
-
- i = i + 1
- END IF
-
- WEND
-
- END
-
- FUNCTION CDate (m, d, y)
- '----------------------------------------------------------------------------
- ' function CDate% encodes the three date parameters into one two-byte
- ' numeric (for INT 21H, function 57H, subfunction 01, set file date/time)
- '----------------------------------------------------------------------------
-
- t = 0
-
- IF d AND &H1 THEN t = t + &H1
- IF d AND &H2 THEN t = t + &H2
- IF d AND &H4 THEN t = t + &H4
- IF d AND &H8 THEN t = t + &H8
- IF d AND &H10 THEN t = t + &H10
-
- IF m AND &H1 THEN t = t + &H20
- IF m AND &H2 THEN t = t + &H40
- IF m AND &H4 THEN t = t + &H80
- IF m AND &H8 THEN t = t + &H100
-
- IF y AND &H1 THEN t = t + &H200
- IF y AND &H2 THEN t = t + &H400
- IF y AND &H4 THEN t = t + &H800
- IF y AND &H8 THEN t = t + &H1000
- IF y AND &H10 THEN t = t + &H2000
- IF y AND &H20 THEN t = t + &H4000
- IF y AND &H40 THEN t = t + &H8000
-
- CDate = t
-
- END FUNCTION
-
- SUB CloseHandle (Handle)
- '----------------------------------------------------------------------------
- ' procedure CloseHandle releases a file handle that was aquired via a
- ' function that returns a file handle to the program.
- '----------------------------------------------------------------------------
-
- DIM regs AS Register
-
- regs.ax = &H3E00
- regs.bx = Handle
-
- Interrupt &H21, regs, regs
-
- IF (regs.flags AND 1) = 1 THEN PRINT "Error"; regs.ax; "closing file"
-
- END SUB
-
- SUB CoPrint (f, b, m$)
- '----------------------------------------------------------------------------
- ' procedure CoPrint prints the string passed in the colors specified by
- ' f and b in the parameter list. If the last character in the string is
- ' a ";", then <CR><LF> is supressed.
- '----------------------------------------------------------------------------
-
- COLOR f, b
- IF RIGHT$(m$, 1) = ";" THEN
- PRINT LEFT$(m$, LEN(m$) - 1);
- ELSE
- PRINT m$
- END IF
-
- END SUB
-
- FUNCTION CTime (h, m, s)
- '----------------------------------------------------------------------------
- ' function CTime% encodes the three time parameters into one two-byte
- ' numeric (for INT 21H, function 57H, subfunction 01, set file date/time)
- '----------------------------------------------------------------------------
-
- t = 0
-
- IF m AND &H1 THEN t = t + &H20
- IF m AND &H2 THEN t = t + &H40
- IF m AND &H4 THEN t = t + &H80
- IF m AND &H8 THEN t = t + &H100
- IF m AND &H10 THEN t = t + &H200
- IF m AND &H20 THEN t = t + &H400
-
- IF h AND &H1 THEN t = t + &H800
- IF h AND &H2 THEN t = t + &H1000
- IF h AND &H4 THEN t = t + &H2000
- IF h AND &H8 THEN t = t + &H4000
- IF h AND &H10 THEN t = t + &H8000
-
- CTime = t
-
- END FUNCTION
-
- FUNCTION FileHandle% (File$)
- '----------------------------------------------------------------------------
- ' function FileHandle% returns a file handle to File$
- '----------------------------------------------------------------------------
-
- DIM regs AS Register
-
- File$ = File$ + CHR$(0)
- regs.ax = &H3D00 + (128)
- regs.ds = VARSEG(File$)
- regs.dx = SADD(File$)
-
- InterruptX &H21, regs, regs
-
- IF (regs.flags AND 1) = 1 THEN
-
- PRINT "Error"; regs.ax; "getting handle on "; File$
-
- CoPrint 0, 7, "Press a key... "
- WHILE INKEY$ = "": WEND
-
- COLOR 7, 0
- FileHandle = 0
-
- ELSE
-
- FileHandle = regs.ax
-
- END IF
-
- END FUNCTION
-
- SUB ParseCommandLine (Drive$, FileSpec$, NewTime$, NewDate$)
- '----------------------------------------------------------------------------
- ' procedure ParseCommandLine takes COMMAND$ and parses it into the
- ' various parameters needed by the program.
- '----------------------------------------------------------------------------
-
- s1 = INSTR(COMMAND$, " ")
- s2 = INSTR(s1 + 1, COMMAND$, " ")
-
- IF LEN(COMMAND$) > 18 AND s1 = 11 AND s2 = 17 THEN
-
- FileSpec$ = RIGHT$(COMMAND$, LEN(COMMAND$) - 17)
-
- IF INSTR(FileSpec$, ":") = 2 THEN
- Drive$ = LEFT$(FileSpec$, 2)
- ELSE
- Drive$ = GetDrive$ + ":"
- END IF
-
- NewDate$ = LEFT$(COMMAND$, 10)
- NewTime$ = MID$(COMMAND$, 12, 5)
-
- CoPrint 7, 0, "Filespec: [;"
- CoPrint 15, 0, FileSpec$ + ";"
- CoPrint 7, 0, "] Date: [;"
- CoPrint 15, 0, NewDate$ + ";"
- CoPrint 7, 0, "] Time: [;"
- CoPrint 15, 0, NewTime$ + ";"
- CoPrint 7, 0, "]"
-
- ELSE
-
- Usage
- END
-
- END IF
-
- e1$ = LTRIM$(RTRIM$(NewTime$))
- e2$ = LTRIM$(RTRIM$(NewDate$))
- e3$ = LTRIM$(RTRIM$(FileSpec$))
-
- IF LEN(e1$) <> 5 OR LEN(e2$) <> 10 OR LEN(e3$) < 1 THEN
- Usage
- END
- END IF
-
- END SUB
-
- SUB Usage
- '----------------------------------------------------------------------------
- ' procedure Usage prints the usage message on the screen if the parameters
- ' do not fulfill the needs of the program.
- '----------------------------------------------------------------------------
-
- PRINT "Usage: SETFDT [";
- CoPrint 15, 0, "mm/dd/yyyy;"
- CoPrint 7, 0, "] [;"
- CoPrint 15, 0, "hh:mm;"
- CoPrint 7, 0, "] [;"
- CoPrint 15, 0, "filespec;"
- CoPrint 7, 0, "]"
-
- END SUB
-
-