DATE$, TIME$ in Loop Can Push System Time Backwards in DOS 3.x (25989)



The information in this article applies to:

  • Microsoft QuickBASIC 3.0
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b

This article was previously published under Q25989

SUMMARY

The following Basic program makes the system time go backwards when run under MS-DOS Versions 3.x.
FOR i = 1 TO 40
   DATE$ = "11/17/87"
   PRINT TIME$
NEXT
				
This behavior is caused by a DOS Versions 3.x problem, not a Basic problem. The problem does not occur in MS OS/2 real mode.

As a workaround, do not reset the date multiple times within a loop.

This information applies to Microsoft QuickBasic Versions 3.00, 4.00, 4.00b, and 4.50 and to Microsoft Basic Compiler Versions 6.00 and 6.00b when run under MS-DOS Versions 3.x.

MORE INFORMATION

For related information concerning Microsoft C, query on the following words:

_DOS_SETDATE and CLOCK and TIME and C


Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB25989