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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Date from Another Computer 4

Status
Not open for further replies.

laado

Programmer
Oct 17, 2002
35
AU
Guys,

I have problem with windows 98 Boxes with users changing dates very often.

As they also use a Clipper Application for Invoicing it prints wrong dates on the invoices.

Can you suggest a way to fix it?

Also is there any way to get date() from a different Computer lets say our File Server.

Thanks

 
Laado,

The code below comes from a FoxPro forum, but the principle is simple enough. Attach to a server with a shared drive, create a file on that machine, and read it's time and date.

That will be a bit behind the server, a few milliseconds in most cases, but it is probably close enough for you.

The code below is from a programmer called Ali Koumaiha and is obviously VFP specific, but a little time shoudl enable you to create a Clipper variant - I will look back in later if you need help.

Code:
FUNCTION ServerTime(server_name)
LOCAL cComp,nHandle,cTime,cFile
cComp = SYS(0)  
cComp = SUBSTR(cComp,1,AT('#',cComp)-1)
cFile = '\\toyzcorp\transfer\'+cComp
nHandle = FCREATE(cFile)
IF nHandle < 0 
    FCLOSE(nHandle)
    IF FILE(cFile)
        ERASE (cFile)
    ENDIF 
    RETURN DATETIME() 
ENDIF 
cTime = FTIME(cFile)
cDate = FDATE(cFile)
cTime = CTOT(DTOC(cDate)+' '+cTime)
FCLOSE(nHandle)
ERASE (cFile)
RETURN cTime 
Ali Koumaiha
Wireless Toyz
Farmington Hills, Michigan


Regards

Griff
Keep [Smile]ing
 
Hi, Laado

As an alternative, you can either run a net time command or put one in a batch file invoking your clipper app.

For example: net time \\<computername> /set /yes

will set the time in the computer it is run on to be the same as that of <computername>.

Jock
 
Griff
Thanks for the Reply..yeah semms pretty staright forward...
I am at home today(saturday here in australia)..don't have access to any clipper book..

I have changed a bit the function ..
i am creating a file..in a shared drive then used
ddate := FDate(cFile)
But getting a error when compiling..error is

BLINKER : 1115 : UTIL.OBJ(UTIL) : 'FTIME' : unresolved external

How can i get this fdate function to work...Is this built in Clipper Function?

Thanks

Laado :)


 
The FDATE s not a Clipper function. What you are remebering is F_DATE, which is an array position of a DIRECTORY() call.
DTRECTORY() returns an array of files. The subset of array positions are:
F_NAME cFile name
F_SIZE cFileSize
F_DATE dDate
F_TIME cTime
F_ATT cAttributes

A call returning the desired data would be:
aDir := directory(cFilename)
dDate := aDir[1,3]

Hope this helps you out.
Sam
 
Thanks GriffMG,JockMullin,Sboomer

for the help. I have managed to work it out the problem.

Thanks alot Guys
You ROCK !!!!!
 
Actually, I learned something too - I have never used the Directory() function to return an array of files.

I've only used the Adir() to do the same thing, but calling it twice!

So thanks Sam

Regards

Griff
Keep [Smile]ing
 
If you go over to NT based OS's from 95/98 reading the directory can be painfully slow so sizing with adir() then using adir() conpounds the problem. Directory() is the way to go.

Ian Boys
DTE Systems Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top