Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting a files date and time stamp in VFP
Message
 
To
15/09/1999 17:23:13
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00265216
Message ID:
00265430
Views:
20
>Does anyone know how to set a files date and time stamp in VFP?

In addition to what the others have told you, the Foxtouch function in Foxtools will do this. Here's the documentation from my "Extended Foxtools Help" file (available in the download section).
Syntax

lnresult = FoxTouch(lcFilename[, lnYear, lnMonth, lnDay,;
  lnHours, lnMinutes, lnSeconds])

lcFilename

A character string representing the fully qualified file name.

lnYear

The 4 digit numeric value of the year.

lnMonth

The numeric month (1 - 12).

lnDay

The day number within the month.

lnHours

The hour number (0 - 23) of the day.

lnMinutes

The minute number of the hour (0 - 59).

lnSeconds

The number of seconds (0 - 59).

Returns

Numeric

Remarks

The function always appears to return 0 even if the file does not exist. If no date and time information is passed, FoxTouch() uses the system date time.

Example

The following example uses FoxTouch() to terminate an executable after 30 days of usage. It increments the seconds to keep track of the number of days. If 30 days have elapsed since the first usage, the function returns .T. The function is written for usage under VFP. FPW users should modify the function due to the absence of the DATETIME() function. The function, however, is not foolproof, since it can be overcome by modifying the system date. Further, it relies on the fact that the seconds are not shown in the Windows 95 Explorer.

FUNCTION ThirtyDays

LPARAMETER pcfile
* pcfile is the fully qualified file name

LOCAL a_dir, lnyear, lnday, lnmonth, lnhour, lnmin, lnsecs,;
  llresult, lnfiles, ldtoday
* Set return value so that if the file isn’t present
* the program will not run.
llresult = .T.
IF FILE(pcfile)
  = ADIR(a_dir, pcfile)
  lnyear = YEAR(a_dir[1, 3])
  ldtoday = DATETIME()
  IF lnyear = 1980
    * First use, so stamp it with today’s
    * date and time with seconds at 0

    lnyear = YEAR(ldtoday)
    lnmonth = MONTH(ldtoday)
    lnday = DAY(ldtoday)
    lnhour = HOUR(ldtoday)
    lnmin = MINUTE(ldtoday)
    lnsec = 0
  ELSE
    * Otherwise, modify the seconds
    * if necessary
    lnmonth = MONTH(a_dir[1, 3])
    lnday = DAY(a_dir[1, 3])
    lnhour = VAL(LEFT(a_dir[1, 4], 2))
    lnmin = VAL(SUBSTR(a_dir[1, 4], 3, 2))
    lnsec = VAL(RIGHT(a_dir[1, 4], 2))
    IF DATE() > a_dir[1, 3] + lnsecs
      lnsec = lnsec + 1
    ENDIF

    llresult = (lnsec = 30)
  ENDIF
  = FoxTouch(pcfile, lnyear, lnmonth, lnday, lnhour, lnmin, lnsec)
ENDIF
RETURN llresult
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform