Updated July 2021; added Example2
? tab(-10, AG_DATETIME); chr(127);
AG_DATETIME (64) returns the system date and time according to the ATE client. The returned information is in the form of date,time,status where date is the decimal value of the separated date format (see IDTIM.SBR 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.
Example1
map1 today,b,4
map1 now,b,4
map1 status,f
? tab(-10,AG_DATETIME);chr(127);
input "",today,now,status
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.
Example2
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().
++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