Reviewed and revised December 2023
tab(-10, AG_DATETIME); chr(127); Tab(-10,x) Syntax Notes
AG_DATETIME (64) queries the system date and time according to the Windows or ATE client.
Parameters
None
Response
A comma delimited list in the form of date, time, status CR where date is the decimal value of the separated date format (see IDTIMxs for details), time is the number of seconds since midnight, and status will be 0 if the operation was successful else a Windows error code.
Example 1
map1 today,b,4
map1 now,b,4
map1 status,f
? tab(-10,AG_DATETIME);chr(127);
input "",today,now,status ! e.g. "108725004,40891,0"
You might then compare this information against the values returned by the DATE and TIME system functions on the server to decide whether the client is reasonably in sync, and if not, you might prompt the client to update the clock on either the server or the client.
Example 2
The following illustrates AG_DATETIME being called via the MX_AGWRAPPER function, which eliminates the need for a separate INPUT statement to retrieve the results. The result string contains three comma-delimited fields which we split out using a utility function Fn'Explode() in SOSLIB:[907,10], although you could use other methods, such as INSTR() or Whole Array Assignment.
++include ashinc:ashell.def
++include sosfunc:fnexplode.bsi
map1 misc
map2 response$,s,100
map2 fields,i,2
map2 today,b,4
map2 clocktime,b,4
map2 status,i,4
? "Querying PC for time ..."
xcall MIAMEX, MX_AGWRAPPER, AG_DATETIME, "", response$
? "Response: ";response$ ! should be sysdate,systime,status
! split out the fields and convert to human readable format...
fields = Fn'ExplodeEx(response$,",",0,today,clocktime,status)
if fields >= 3 and status = 0 then
? ODTIM(today,clocktime,0)
else
? "Error"
endif
end