Microsoft KB Archive/190624

= PRB: SYS(2018) May Return More Than the Message Parameter =

Article ID: 190624

Article Last Modified on 12/11/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q190624



SYMPTOMS
When a table is created programmatically, the Check clause can be used to perform field level validations. When a field level error occurs, either the SYS(2018) or the AERRORS function can be used to display the source of the error. In Visual FoxPro 3.0, the error message parameter that was involved in the generated error was returned. This behavior is different in Visual FoxPro 5.0 and 6.0. In the latter versions of Visual FoxPro, the entire error message is returned by default.



RESOLUTION
To work around this behavior use the Error cause in the CREATE TABLE, Check statement, as shown in the MORE INFORMATION section.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Run the following code to see the behavior. When the code executes, the program continues when an error occurs and the error is displayed using SYS(2018) and the AERRORs array. Run the code and first do not select the work around and you will see the default error message parameter. If you want to see the work around, the CREATE TABLE with the ERROR clause is used.

Sample Code
*-- Code begins here. CLEAR ON ERROR * IF ADIR(myTestFiles, "sys2018*.dbc") > 0 nErase=MESSAGEBOX("Erase SYS(2018) Files?",4) ENDIF IF nErase = 6 CLOSE DATA ERASE sys2018.* CREATE DATA sys2018 OPEN DATA sys2018 nError = MESSAGEBOX("Workaround?",4) IF nError = 6 CREATE TABLE sys2018 (NAME c(10) CHECK NAME="Moe" ;             ERROR "NAME") ELSE CREATE TABLE sys2018 (NAME c(10) CHECK NAME="Moe") ENDIF ENDIF

INSERT INTO sys2018 VALUES ("NotMoe")

&&This causes a validation error. ?"SYS(2018) = " + SYS(2018) ?     ?      =AERROR(aTest) DISPLAY MEMO LIKE aTest CLOSE DATA ALL ON ERROR *-- Code ends here. 

After the preceding program is finished, the files created can be deleted by issuing the following command: ERASE SYS2018.*

