Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronizing time & date between foxpro 2.6 applications / net time

Status
Not open for further replies.

filibuster

Programmer
Feb 25, 2001
29
DE
Hi,

I am looking for a solution how to synchronize date & time between foxpro applications on different computers which might be running for a certain period (e.g. 1 week) without restarting.

The windows command "net time" ( is working fine in my environment on the DOS prompt.

However, a running instance of foxpro 2.6 / windows only picks up changes in the system date (date() function), but changes in the system time (time() function) are ignored by FoxPro.

I could capture the output of "net time" in foxpro or build my own time server, but that would still leav the internal foxpro time() function unchanged.

any suggestions ?
thanks
 
As I recall, Fox grabs the system time upon starting then uses it's own internal timer + system ticks to keep time. I think the only way to update it is to restart Fox.
Dave S.
 
FPD gets the time from the system.
Start FPD in a dos box, print the time (? time()) get back into Windows and reset the time, activate your FPD in the dos box and ? time() again and you'll see that FPD has updated to the new time.
I figure you could jump out and run NET TIME at just about any time and FPD will auto update. Your user will hardly notice this on a pentium 90 or faster.
Ken F
 
tilltek - I could NOT reproduce the behaviour you describe, neither in FoxPro DOS 2.6 nor FoxPro Windows 2.6. Are you using different versions of Fox ?
 
tilltek - you might be right, though; I ran four different tests, and could reproduce the behavour you describe in one case. It seems to a VDM related issue (I'm a novice to this, just found an article in the knowledge db: tilltek's case seems to be case (1). Details see below:

(1) FoxPro DOS 2.6, change time from FoxPro

- start FoxDos 2.6
- run net time from within FoxPro ("!net time")

--> time is updated in DOS and also in FoxPro

(2) FoxPro DOS 2.6, change time outside FoxPro

- start FoxDos 2.6
- start new DOS Prompt, run net time in this dos prompt

--> time is not updated

(3) FoxPro Win 2.6, change time from FoxPro

like (1), but using FoxPro Win 2.6

--> time is not updated

(4) FoxPro Win 2.6, change time outside FoxPro

like (2), but using FoxPro Win 2.6

--> time is not updated

so the only successful test was (1) which seems to indicate that changes to the system clock are only propagated to 16 bit programs when the time had been changed within the same VDM.

now the question is: can I execute a command line (using "!" or "RUN") from FoxPro Windows without creating a new VDM ?
 
"!"' or "RUN" actually executes COMMAND.COM or CMD.EXE.
"! Some.Exe" creates an instance of that EXE though, so if you run "!net time", an instance of NET gets created but I don't think another VDM does. The biggest drawback with that though is the infamous memory leaks. Shelling out like that will eventually cause you grief.
Dave S.
 
I've tried in on 1: AMD200 Win98, 2: AMD500 Win98se and 3: AMD 1200 Win XP.
In all instances, running net time updated automatically in a running FPD.
Here's something to think on.
If FPD does not use the system time, but rather, keeps track of time by it self, why can't one change or set the time from within FPD? The fact that you can't would lead one to believe that FPD somehow uses the system time.
I guess the infamous memory leak could come into things. Are these systems used 24/7? Could they be shut down now and then?
I have a group of stores that have had systems running several (9) years with an automatic shut down of my Foxpro app at 6.30 PM (after they close), PcAnywhere is then loaded so we can do things via the phone and then an auto reboot takes place at 8 am (before the store opens). There is evidence to suggest that this 24/7 uptime with a reboot once a day prolongs the life of the computer, but that's another story.
By the way, if you have Windows running in the background, I'd reboot at least once a day anyway.
Ken F
 
It's not a pure 24x7 system, so the restart option is a valid one, and we'll probably go that way. As you said, restarting a windows system from time to time is not a bad thing.

We're also looking to use VFP for the long running parts of the application (the time is updated properly in VFP).

FoxPro DOS is fine, by the way. I was looking mainly at FoxPro 2.6/Windows.

FYI: I created another thread in the experts-exchange forums:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top