Microsoft KB Archive/221702

= FIX: C0000005 Fatal Error w/ ISBLANK and Array Prop in Init =

Article ID: 221702

Article Last Modified on 10/16/2002

-

APPLIES TO


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

-



This article was previously published under Q221702



SYMPTOMS
Placing an ISBLANK function in the Init of a form created programmatically causes the following error in Visual FoxPro 6.0:

Fatal Error C0000005

In Visual FoxPro 5.0x, the following error appears:

An application has occurred

and an application error log is being generated.

VFP.exe

Exception: access violation(0xc0000005); address:

If the ISBLANK function is in the Init event of a form create with the Form Designer, no error occurs but the Show event of the form never fires. Therefore, the form flashes and disappears.



RESOLUTION
To work around this behavior, put parentheses around the array variable. In the example below, this works:

IIF(isblank((THISFORM.WorkerData[2])) while this does not: IIF((isblank(THISFORM.WorkerData[2])) In Steps to Reproduce Behavior below, comment and uncomment the specified lines of code as indicated in the example and it operates as expected.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed



Steps to Reproduce Behavior
  Create a program that contains the following code: ***Code begins here PUBLIC oisblkerr oisblkerr=CREATEOBJECT("arrform") oisblkerr.SHOW READ EVENTS RELEASE oisblkerr RETURN

DEFINE CLASS arrform AS FORM DIMENSION myar[3],larray[4,3] ADD OBJECT text1 AS TEXTBOX ADD OBJECT cmdexit AS COMMANDBUTTON cmdexit.TOP = THISFORM.text1.TOP+THISFORM.text1.HEIGHT+10 text1.width=150

PROCEDURE init THISFORM.myar[1]="John" THISFORM.myar[2]="X." THISFORM.myar[3]="Smith" THISFORM.text1.VALUE = ALLTRIM(THISFORM.myar[1])+" "+IIF(isblank(THISFORM.myar[2]),;        "",THISFORM.myar[2])+ " "+RTRIM(THISFORM.myar[3]) ENDPROC
 * Comment this line below to prevent problem.
 * Uncomment these lines below for it to work properly
 * !*      THISFORM.text1.VALUE = ALLTRIM(THISFORM.myar[1])+" "+IIF(isblank((THISFORM.myar[2])),;
 * !*         "",THISFORM.myar[2])+ " "+RTRIM(THISFORM.myar[3])

PROCEDURE cmdexit.CLICK THISFORM.RELEASE CLEAR EVENTS RETURN ENDPROC ENDDEFINE  Run the program.

Depending on what code is commented, the form either appears or Visual FoxPro crashes with one of the errors mentioned in the Symptoms section.

To see the behavior in a form created with the Form Designer, follow these steps:

 Create a form. Add the property "WorkerName" to the form. This will store the concatenated name.</li> Add the property "WorkerData[3]" to the form. This is an array to store the parts of the name.</li>  In the Init event of the form, add the following code: THISFORM.WorkerData[1] = "JOHN" THISFORM.WorkerData[2] = "X" THISFORM.WorkerData[3] = "SMITH"

THISFORM.WorkerName = THISFORM.WorkerData[1] + ; IIF((isblank(THISFORM.WorkerData[2])), " ", " " + THISFORM.WorkerData[2] + " "); + THISFORM.WorkerData[3] </li> Save the form and run it. Notice that the form flashes and disappears.</li> Modify the form and edit the Init event. Comment the code that causes the error and uncomment the code that functions properly.</li> Run the form and notice that it appears on the screen.</li></ol>
 * This code causes the error
 * This code does not cause the error
 * !* THISFORM.WorkerName = THISFORM.WorkerData[1] + ;
 * !*    IIF(isblank((THISFORM.WorkerData[2])), " ", " " + THISFORM.WorkerData[2] + " ");
 * !*    + THISFORM.WorkerData[3]

Keywords: kbbug kbfix kbxbase kboop kbcontainer kbctrl kbvs600sp3fix KB221702

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.