BUG: SYS(1271) Used in Property of a Class Crashes Visual FoxPro (258241)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
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:
<ClassProperty> = 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.
- From the View Classes interface of the Form Controls toolbar, add the MyClass Visual Class Library.
- Add the MyCustom class to the form.
- Add the following code to the click event of the command button:
WAIT WINDOW ThisForm.MyCustom1.MyProperty
- Run the form, saving it as whatever you wish.
- Click the Command1 command button, and note that it produces a WAIT WINDOW message that contains the name and full path of the form.
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/15/2002 |
---|
Keywords: | kbBug kbCodeSnippet kbDSupport kbXBase KB258241 |
---|
|