PRB: SYS(3) Returns Duplicate Filenames

ID: Q114435

The information in this article applies to:

SYMPTOMS

The purpose of the SYS(3) function is to return a unique filename when it is called. Under certain circumstances, duplicate names may be returned.

CAUSE

This behavior occurs with some processors that run at high speeds.

RESOLUTION

To avoid this problem, increase the time between calls of the SYS(3) function. For example, add the following line:

   =INKEY(.001)

This command forces FoxPro to wait for .001 seconds before issuing the next command.

MORE INFORMATION

Steps to Reproduce Problem

Create and run the following program:

   SET STATUS BAR OFF
   SET STATUS OFF
   SET TALK OFF
   CLEAR

   CREATE CURSOR systest (naam C(10))
   DO WHILE RECNO() < 1000
      APPEND BLANK
      REPLACE naam WITH SYS(3)
   ENDDO

   NumberOfRecords=RECCOUNT()
   ? STR(NumberOfRecords)
   INDEX ON naam TAG naam UNIQUE
   COUNT TO A
   ?STR(A)
   ?"        ----"
   ?STR(NumberOfRecords-A)

Note that the Total number of records (the first number printed) may differ from the number of unique records (the second number printed).

Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b 2.60 repeat identical same duplicate KBCategory: kbprg kbprb KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995