/* Time routines for MS-Windows V3.1 & V3.11 */ /* Written by Peter C. Headland 1995-12-11 */ /* This code is Copyright (C) 1995 Matrix Link Limited */ /* You may use and distribute this code freely so long */ /* as you ensure that this Copyright notice is included */ /* in any copies you make. */ /* Please send comments and improvements to: */ /* Peter_Headland@matrixlk.demon.co.uk */ /* ** Functions in the DLL. */ /* Get the Version number of the DLL */ PROCEDURE MLGetVer EXTERNAL 'mldttm.dll': DEF RETURN PARAMETER sh_Value AS SHORT. END PROCEDURE. /* Set the PC's date */ PROCEDURE MLSetDate EXTERNAL 'mldttm.dll': DEF INPUT PARAMETER sh_Year AS SHORT. DEF INPUT PARAMETER sh_Month AS SHORT. DEF INPUT PARAMETER sh_Day AS SHORT. DEF RETURN PARAMETER sh_Value AS SHORT. END PROCEDURE. /* Set the PC's time */ PROCEDURE MLSetTime EXTERNAL 'mldttm.dll': DEF INPUT PARAMETER sh_Hour AS SHORT. DEF INPUT PARAMETER sh_Minute AS SHORT. DEF INPUT PARAMETER sh_Second AS SHORT. DEF RETURN PARAMETER sh_Value AS SHORT. END PROCEDURE. /* Set the PC's time using Progress time (seconds since midnight) */ PROCEDURE MLSetProgressTime EXTERNAL 'mldttm.dll': DEF INPUT PARAMETER sh_ProgressTime AS LONG. DEF RETURN PARAMETER sh_Value AS SHORT. END PROCEDURE. /* ** Sample of use - synchronising the local PC with a remote server. */ DEF VAR ldt_Today AS DATE NO-UNDO. DEF VAR lin_RC AS INT NO-UNDO. /* Show the old date/time */ MESSAGE TODAY STRING (TIME, 'HH:MM:SS') VIEW-AS ALERT-BOX INFO BUTTONS OK. SESSION:TIME-SOURCE = LDBNAME ('DICTDB'). /* ** A race hazard exists as we pass through midnight. */ /* 1. The time must be done before the day */ RUN MLSetProgressTime (TIME, OUTPUT lin_RC). /* 2. Get the date just once */ ldt_Today = TODAY. RUN MLSetDate (YEAR (ldt_Today), MONTH (ldt_Today), DAY (ldt_Today), OUTPUT lin_RC). /* Show the new date/time */ SESSION:TIME-SOURCE = 'LOCAL'. MESSAGE TODAY STRING (TIME, 'HH:MM:SS') VIEW-AS ALERT-BOX INFO BUTTONS OK.