home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / pb / library2 / pbtouch.bas < prev    next >
BASIC Source File  |  1990-04-08  |  3KB  |  100 lines

  1.  ' PowerBASIC version
  2.  ' PBTOUCH.BAS
  3.  $Compile EXE
  4.  $LIB ALL OFF
  5.  $ERROR ALL OFF
  6.  DEFINT a-z
  7.  %True = -1
  8.  %False = 0
  9.  PUBLIC FileTime&,FileDate&,TUError
  10.  $Link "Touchu.Pbu"
  11.  $Link "FindFile.Pbu"
  12.  
  13.  
  14.  FUNCTION DOHelp
  15.  PRINT " PBTouch  (c) 1990 Barry Erick"
  16.  PRINT
  17.  PRINT "Syntax is:"
  18.  PRINT " PBTOUCH filename switches"
  19.  PRINT "The switches are:"
  20.  PRINT "    -D  Use DOS Time and Date   -T  use the passed time:
  21.  PRINT " When using passed time, the format is:
  22.  PRINT "PBTOUCH filename -T=date=time"
  23.  PRINT "where:
  24.  PRINT "     date is in MM/DD/YY format  and"
  25.  PRINT "     time is in HH:MM:SS format or"
  26.  PRINT "     time is in HH:MM format"
  27.  PRINT
  28.  PRINT "Wildcard file names are allowed."
  29.  
  30.  ' If you can see this source, you
  31.  ' may want to see the pbu file source for additional
  32.  ' things that you may do. Like update a file and
  33.  ' then reset the time stamp to the original.
  34.  END 255
  35.  END FUNCTION
  36.  
  37.  'get the command line.. the only way for this to work
  38.  IF COMMAND$ = "" THEN
  39.     a = doHelp
  40.  ELSEIF INSTR(COMMAND$,ANY "-/") = 0 THEN
  41.     a = DoHelp
  42.  ELSEIF LEFT$(COMMAND$,2)="/?" OR UCASE$(LEFT$(COMMAND$,2))="/H"_
  43.         OR  LEFT$(COMMAND$,2) ="-?" OR UCASE$(LEFT$(COMMAND$,2))="-H" THEN
  44.     a = DoHelp
  45.  ELSE
  46.     OurCommand$ = COMMAND$
  47.  'get filename
  48.     spcloc = INSTR(COMMAND$,ANY "-/")
  49.     FileSpec$ = Ltrim$(Rtrim$(MID$(COMMAND$,1,spcloc-1)))
  50.     'parce off any drive or path information
  51.     ' check for drivespec
  52.     DriveSpec = INSTR(filespec$,":")
  53.     PathSpec = INSTR(FileSpec$,"\")
  54.     IF PathSpec > 0 THEN
  55.      ' check if more
  56.        PPtr = PathSpec+1
  57.        DO
  58.            morePath  = INSTR(PPtr,FileSpec$,"\")
  59.            IF MorePath = 0 THEN EXIT LOOP
  60.            PPTr = MorePath + 1
  61.        LOOP
  62.        DrivePath$ = MID$(FileSpec$,1,PPTr-1)
  63.     ELSE
  64.        DrivePath$ = MID$(FileSpec$,1,DriveSpec)
  65.     END IF
  66.     f$ = FindFirst$(FileSpec$)
  67.     IF f$ = ""THEN EXIT IF
  68.     FileName$ = DrivePath$+ F$
  69.     InFirst = %True
  70.     DO
  71.         IF NOT InFirst% THEN
  72.            f$ = FindNext$
  73.            IF f$ = "" THEN EXIT LOOP
  74.            FileName$ = Drivepath$ + F$
  75.         END IF
  76.         InFirst% = %False
  77.         WhatAction$ = MID$(OurCOMMAND$,spcloc+1,1)
  78.         SELECT CASE UCASE$(WhatAction$)
  79.                CASE "D"
  80.                     CALL Touch(FileName$,"DOS")
  81.                CASE "T"
  82.                     'get the passed time and date
  83.                     'Check.. must have two equals
  84.                     f = INSTR(OurCOMMAND$,"=")
  85.                     s = INSTR(f+1,OurCOMMAND$,"=")
  86.                     IF f = 0 OR s = 0 THEN
  87.                        TUError = 2
  88.                        EXIT SELECT
  89.                     END IF
  90.                     da$ = MID$(Ourcommand$,f+1,(s-1)-(f))
  91.                     ti$ = MID$(OurCommand$,s+1)
  92.                     CALL TouchwithThis(FileName$,da$,Ti$)
  93.                CASE ELSE
  94.                     TUError = 2
  95.                     EXIT SELECT
  96.         END SELECT
  97.     LOOP
  98.  END IF
  99.  END (TUError)
  100.