BUG: OBJVAR() Returns Incorrect Values When Used in Screen

Last reviewed: April 30, 1996
Article ID: Q123005
The information in this article applies to:
  • Microsoft FoxPro for Windows, version 2.6
  • Microsoft FoxPro for MS-DOS, version 2.6

SYMPTOMS

When used in a screen, OBJVAR() returns incorrect values for a current or specified Screen object that has a preceding Push/Radio button object with more than one prompt as following:

  1. A NULL value is returned if the current or specified Screen Object is immediately preceeded by a Push/Radio button that has more than one Prompt.

  2. The name of the memory variable, array element, or field associated with the object Preceeding the current or specified object, if the Current/Specified object and the Preceding Push/Radio button object have one or more screen objects between them.

  3. If two radio buttons exist on a screen, a NULL value is returned by the OBJVAR() function for objects past the 2nd radio button.

  4. The OBJVAR() function inconsistently returns a NULL for objects past approximately 20 objects (other than radio buttons).

RESOLUTION

You can use one of the following methods to work around this situation:

  1. Do not use Radio or Push button objects with multiple prompts before or after the object for which you do not want OBJVAR() to return a NULL. Instead, create a separate Radio or Push Button object for each of the prompt that needs to be defined.

  2. Use VARREAD() or SYS(18) functions instead of OBJVAR().

STATUS

Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new screen by using this command:

          MODIFY SCREEN TEST.SCR
    

  2. Create a Push Button or a Radio Button object by using this program:

          Type = Normal
          Push/Radio Button Prompts = ONE; TWO
          Variable = MOBJ1
          Options = Horizontal/Vertical
          Place the following code in the Valid clause:
    
               DO CASE
                   CASE MOBJ1=1
                      WAIT WINDOW "ONE"
                   CASE MOBJ1=2
                      WAIT WINDOW "TWO"
               ENDCASE
    
    

  3. Create a Field Object by using this code:

          Input Field = GET
          Input = MOBJ2
          OPTIONS = Select Field on Entry
    

  4. Create another Push/Radio button similar to the one described in Step 2, except use MOBJ3 as the variable name.

  5. Place the following code in the "Screen Setup Code" clause:

          ON KEY LABEL ALT+O WAIT WINDOW "OBJVAR() = "+OBJVAR()
    

  6. Place "ON KEY" command in the "On Screen Exit (Valid)" clause.

  7. Generate the Screen, and run it using the RUN command.

  8. Select the First Push/Radio Button (1st Screen Object), and press ALT+O. "OBJVAR() = MOBJ1" will be displayed in the wait window. So far OBJVAR() is working correctly.

  9. Select The Get Field (2nd Screen Object). Then press ALT+O. Only "OBJVAR() =" is displayed in the wait window. This means OBJVAR() returned a NULL value. This step produces the first symptom.

  10. Select the second Push/Radio Button (3rd Screen Object), and press

        ALT+O. This time "OBJVAR()= MOBJ2" will be displayed in the Wait Window
        instead of "OBJVAR()= MOBJ3." This goes to prove that OBJVAR() is
        returning the variable name for the previous object (2nd Screen Object)
        instead of the current screen object (3rd Screen Object). This step
        produces the second symptom.
    

  11. Exit the Screen. Then open it by using the "MODIFY SCREEN" command.

  12. Change the first Push/Radio Buton (1st Screen Object) by using this

        code:
    

           Type = Normal
           Push/Radio Button Prompts = ONE
           Variable = MOBJ1
           Options = Horizontal/Vertical
           Valid = WAIT WINDOW "ONE"
    

  13. Generate and run the Screen.

  14. Repeat steps 8 thru 10. Notice that OBJVAR() now returns correct'

        information because none of the Screen objects are preceeded by a
        Push/Radio Button with more than two prompts.
    


Additional reference words: FoxWin FoxDos 2.60 buglist2.60 SBuilder
KBCategory: kbtool kbprg kbbuglist
KBSubcategory: FxtoolSbuilder


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.