PRB: SUBSTR(SYS(2015),3,10) as Alias Name Causes Syntax Error (196647)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 5.0
  • Microsoft Visual FoxPro for Windows 5.0a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft FoxPro for Windows 2.5
  • Microsoft FoxPro for Windows 2.5a
  • Microsoft FoxPro for Windows 2.5b
  • Microsoft FoxPro for Windows 2.6
  • Microsoft FoxPro for Windows 2.6a
  • Microsoft FoxPro for UNIX 2.6
  • Microsoft Visual FoxPro for Macintosh 3.0b
  • Microsoft FoxPro for Macintosh 2.5b
  • Microsoft FoxPro for Macintosh 2.5c
  • Microsoft FoxPro for Macintosh 2.6a
  • Microsoft FoxPro for MS-DOS 2.0
  • Microsoft FoxPro for MS-DOS 2.5
  • Microsoft FoxPro for MS-DOS 2.5a
  • Microsoft FoxPro for MS-DOS 2.5b
  • Microsoft FoxPro for MS-DOS 2.6
  • Microsoft FoxPro for MS-DOS 2.6a

This article was previously published under Q196647

SYMPTOMS

Programs that have been working properly using the SUBSTR() and SYS(2015) functions suddenly produce a syntax error.

CAUSE

The assignment of an illegal value, or memory variable containing an illegal value, to a table, alias or array name.

RESOLUTION

The solution to the problem is to make sure that the result of the SUBSTR() and
SYS(2015) functions do in fact begin with a letter or an underscore as required.

  • Use the entire result of the SYS(2015) function, without truncating through the SUBSTR() function. This gives a leading character of an underscore '_'.
          x = SYS(2015)
    						
    -or-
  • Use a concatenated string that adds a character letter to the beginning of the desired string. For example:
          x = SUBSTR(SYS(2015), 3, 10)
          x = "A" + x
On operating systems that are limited to eight character file names, you can use the following code:

   x = "_" + SUBSTR(SYS(2015), 4)
				

STATUS

This behavior is by design.

MORE INFORMATION

Depending upon the character string length and logic you use to obtain it, the syntax error may start occurring on computers with a system date of November 18, 1998.

For example, for computer system dates between 11/17/1998 and 11/10/1999 the leading character of a value assigned to variable 'x' will be a numeric digit:
   x = SUBSTR(SYS(2015), 3, 10)
				
NOTE: Future date periods may also cause a similar problem.

Steps to Reproduce Behavior

Important: Remember to change your computer system clock to the correct date and time after completing the following tests.

Set the computer system date to any date between November 18, 1998 and November 10, 1999, using the Date/Time Properties in Windows Control Panel.

Note that the leading character of the value assigned to the memory variable is a numeric digit.

Alias Names

In the specific case of November 18th, 1998 run the following code:
   ? DATE()
   x=SYS(2015)
   ? x
   y=SUBSTR(x,3,10)
   ? y
   CREATE CURSOR (y) (field1 c(10))
				


Note that the leading character of the value assigned to the memory variable 'y' is a numeric digit, depending upon the computer system date. Observe that the command to create a cursor with that name produces a syntax error.

Array Names

  x=SUBSTR(SYS(2015), 3, 10)
   DIMENSION &x(1,2)
				
Running the preceding code returns the following error message:
Command contains unrecognized phrase/keyword.

REFERENCES

For additional information about the ALIAS parameter of the USE command, the SYS(3) or SYS(2015) functions, please see the following article in the Microsoft Knowledge Base:

97633 PRB: Alias Problems with Table Name Starting with Number

Microsoft FoxPro Help: search on: "USE command"; "ALIAS argument"; "SYS(3) Legal File Name"; "SYS(2015) - Unique Procedure Name"

(c) Microsoft Corporation 1998. All Rights Reserved. Contributions by Perry Newton, Microsoft Corporation.

Modification Type:MinorLast Reviewed:3/7/2005
Keywords:kbDatabase kbprb kbXBase kbXPlatform KB196647 kbAudDeveloper