Microsoft KB Archive/196647

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

Article ID: 196647

Article Last Modified on 3/7/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.6 for SCO/UNIX
 * Microsoft Visual FoxPro 3.0b for Macintosh
 * Microsoft FoxPro 2.5b for Macintosh
 * Microsoft Visual FoxPro 2.5c for Macintosh
 * Microsoft FoxPro 2.6a Professional Edition for Macintosh
 * Microsoft FoxPro 2.0
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.6 for MS-DOS
 * Microsoft FoxPro 2.6a Standard Edition

-



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.

