Microsoft KB Archive/258241

= BUG: SYS(1271) Used in Property of a Class Crashes Visual FoxPro =

Article ID: 258241

Article Last Modified on 10/15/2002

-

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 Q258241



SYMPTOMS
Using the SYS(1271) function in the property of a class causes Visual FoxPro to crash with the following error message:

The instruction at "memory address" referenced memory at "memory address". The memory could not be "written".



CAUSE
The SYS(1271) function requires that a parameter be passed that references the form of which a specified instantiated object is a member. If the parameter syntax, when used outside the SYS(1271) function as follows:  = ThisForm produces the following error:

Data type is invalid for this property.

then use of the preceding syntax as a parameter within the SYS(1271) function can cause Visual FoxPro to crash.



RESOLUTION
The purpose of the SYS(1271) function is to return the name of the .scx file in which the specified instantiated object is stored. Due to the order of object instantiation, the SYS(1271) function is unable to return its expected value until the form itself is fully instantiated. Therefore, using the SYS(1271) function directly within a property, whether that of an object or of the form itself, does not produce its intended result.

The proper use of the SYS(1271) function is to call it from within a method. If you want to store the name of the instantiated object's host .scx file to a property, that can be done from the Init Event of the class as demonstrated in the following example:  Create a new class based on Custom, name it MyCustom, and then store it in Class Library MyClass. Add a new property to the MyCustom class called MyProperty .  Add the following code to the Init Event of the MyCustom class: This.MyProperty = SYS(1271,ThisForm)  Close and save the MyCustom class. Create a new form. Add a command button to the form.</li> From the View Classes interface of the Form Controls toolbar, add the MyClass Visual Class Library.</li> Add the MyCustom class to the form.</li>  Add the following code to the click event of the command button: WAIT WINDOW ThisForm.MyCustom1.MyProperty </li> Run the form, saving it as whatever you wish.</li> Click the Command1 command button, and note that it produces a WAIT WINDOW message that contains the name and full path of the form.</li></ol>

<div class="status_section">

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

<div class="moreinformation_section">

Steps to Reproduce Behavior
In order to avoid losing unsaved work or data, take the the following steps in a new session of Microsoft Visual FoxPro: <ol> Create a new class based on any class.</li> Add a new property to the class.</li>  In the newly added property, add the following code: =SYS(1271,ThisForm) This produces the following error message:

The instruction at "memory address" referenced memory at "memory address". The memory could not be "written".

</li></ol>

Keywords: kbbug kbxbase kbcodesnippet kbpending KB258241

-

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

© Microsoft Corporation. All rights reserved.