TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: BRIAN MCLAUGHLIN
date: 1995-08-12 15:00:00
subject: TOUCH UTILITY SOURCE 1/3

I just finished writing that Touch utility I've been meaning to get
around to. [BTW, a Touch utility changes the date/time stamp on
files.]
Since August is always so slow, I'm posting the source to liven it
up. Cheers!
'----------------------------- START CODE -------------------------
' TOUCH.BAS -  changes the date and time stamp on files
'
' Written by Brian McLaughlin. Donated to the public domain 8/12/95.
'
' HINT: To see the "docs", read the SUB called ShowHelpMessage. For
' you batch file fiends it returns an errorlevel of 1 if it detects
' any kind of error. Feel free to elaborate on it.
'-------------------------------------------------------------------
 $LIB ALL OFF
 DECLARE SUB Report (Message$)
 DECLARE SUB ShowHelpMessage ()
 DECLARE SUB FillFiles (FSpec$, FArray$())
 DECLARE SUB SetDateTime (BYVAL Handle%, BYVAL DateNum??, BYVAL TimeNum??)
 DECLARE FUNCTION CountFiles% (FileSpec$)
 DECLARE FUNCTION ConvertDate?? (DateSpec$)
 DECLARE FUNCTION ConvertTime?? (TimeSpec$)
 DECLARE FUNCTION ArgC% ()
 DECLARE FUNCTION ArgV$ (WhichArg%)
 DECLARE FUNCTION Tokenize$ (Mian$, Delim$, Index%)
 DECLARE FUNCTION GETSTRLOC& (BYVAL Handle%)
 DECLARE FUNCTION GETSTRALLOC& (BYVAL Bytes%)
'///////////////////////////  START OF MAIN \\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 DIM StdOut AS SHARED INTEGER
 StdOut = FREEFILE
 OPEN "CON" FOR OUTPUT AS StdOut
 IF ArgC%  3 THEN ShowHelpMessage   ' must be three parameters!
 FileSpec$ = ArgV$(1)
 DateSpec$ = ArgV$(2)
 TimeSpec$ = ArgV$(3)
 FileCount% = CountFiles%(FileSpec$)
 IF FileCount% THEN
   DIM DYNAMIC FileArray$ (1 TO FileCount%)
   FillFiles FileSpec$, FileArray$()
 ELSE
   Report ""
   Report "No matching files."
   END 0
 END IF
 DateNum?? = ConvertDate??(DateSpec$)
 TimeNum?? = ConvertTime??(TimeSpec$)
 FOR Count% = 1 TO FileCount%
   FileName$ = FileArray$(Count%)
   Num% = FREEFILE
   OPEN FileName$ FOR BINARY AS Num%
   Handle% = FILEATTR(Num%, 2)
   SetDateTime Handle%, DateNum??, TimeNum??
   CLOSE Num%
 NEXT Count%
 END 0
'///////////////////////  END OF MAIN \\\\\\\\\\\\\\\\\\\\\\\\\\\\
'=============================================================================
 FUNCTION ConvertDate?? (DateSpec$)
'=============================================================================
 DateSpec$ = RTRIM$(LTRIM$(DateSpec$))
 Delim$ = "/-"
 Index% = 0
 AMonth$ = Tokenize$(DateSpec$, Delim$, Index%)
 ADay$ = Tokenize$(DateSpec$, Delim$, Index%)
 AYear$ = Tokenize$(DateSpec$, Delim$, Index%)
 Year?? = VAL(AYear$)
 IF Year?? < 80 THEN
   Year?? = Year?? + 2000
 ELSEIF Year?? < 100 THEN
   Year?? = Year?? + 1900
 END IF
 Year?? = Year?? - 1980
 SHIFT LEFT Year??, 9
 Month?? = VAL(AMonth$)
 IF ISTRUE(Month?? > 12) OR ISTRUE(Month?? < 1) THEN
   Report "Invalid date spec: " + DateSpec$
   END 1
 END IF
 SHIFT LEFT Month??, 5
 Day?? = VAL(ADay$)
 IF ISTRUE(Day?? > 31) OR ISTRUE(Day?? < 1) THEN
   Report "Invalid date spec: " + DateSpec$
   END 1
 END IF
 ConvertDate?? = Year?? + Month?? + Day??
END FUNCTION
'=============================================================================
 FUNCTION ConvertTime?? (TimeSpec$)
'=============================================================================
 TimeSpec$ = RTRIM$(LTRIM$(TimeSpec$))
 Delim$ = ":"
 Index% = 0
 Hour$ = Tokenize$(TimeSpec$, Delim$, Index%)
 Minute$ = Tokenize$(TimeSpec$, Delim$, Index%)
 Second$ = Tokenize$(TimeSpec$, Delim$, Index%)
 Hours?? = VAL(Hour$)
 IF ISTRUE(Hours?? > 24) OR ISTRUE(Hours?? < 1) THEN
   Report "Invalid time spec: " + TimeSpec$
   END 1
 END IF
 SHIFT LEFT Hours??, 11
 Minutes?? = VAL(Minute$)
 IF ISTRUE(Minutes?? > 59) OR ISTRUE(Minutes?? < 0) THEN
   Report "Invalid time spec: " + TimeSpec$
   END 1
 END IF
 SHIFT LEFT Minutes??, 5
 Seconds?? = VAL(Second$)
 IF ISTRUE(Seconds?? > 59) OR ISTRUE(Seconds?? < 0) THEN
   Report "Invalid time spec: " + TimeSpec$
   END 1
 END IF
 Seconds?? = Seconds?? \ 2   'integer divide by 2
 ConvertTime?? = Hours?? + Minutes?? + Seconds??
END FUNCTION
>>> Continued to next message
 * SLMR 2.1a * MAXLIB For PB v1.1 - Access arrays and files in EMS/XMS!
--- WILDMAIL!/WC v4.12 
---------------
* Origin: Com-Dat BBS - Hillsboro, OR. HST DS (1:105/314.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.