PRB: How to Clear Popup Bars in a List Object

Last reviewed: February 16, 1996
Article ID: Q117931
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
  • Microsoft FoxPro for Macintosh, versions 2.5b, 2.5c

SUMMARY

To have a popup list display a diminishing number of elements, possibly including an empty list, follow the steps shown below. (Two procedures are given; one for FoxPro for Windows and FoxPro for Macintosh, and one for FoxPro for MS-DOS.)

MORE INFORMATION

FoxPro for Windows or FoxPro for Macintosh

  1. Start FoxPro for Windows or FoxPro for Macintosh. From the File menu, choose New, select Screen, and then choose the New button.

  2. From the Screen menu, choose Layout.

  3. Under Options, choose the Code button, choose the Screen Setup Code button, and then choose OK twice. In the "Untitled - Setup" window, type the following code:

          SET SAFETY OFF
          CREATE TABLE employee ;
    
             (name C(20),addr C(30),city C(30),zip C(5),;
             salary N(8,2),comments m)
          SET SAFETY ON
          INSERT INTO employee (name) VALUE ('Emp1')
          INSERT INTO employee (name) VALUE ('Emp2')
          INSERT INTO employee (name) VALUE ('Emp3')
          INSERT INTO employee (name) VALUE ('Emp4')
          INSERT INTO employee (name) VALUE ('Emp5')
          SELECT name FROM employee INTO ARRAY mpoparray
          mpopval=''     && two single quotation marks
    
       NOTE: The SELECT-SQL command yields the array (mpoparray) that will be
       used in the list box you will define in step 6. The mpopval variable
       will  also be used by this list box.
    
       When you have finished typing the code, close the "Untitled - Setup"
       window.
    
    

  4. Click the Button tool, and create a button set with two prompts: The first button will perform the action; the second will terminate the READ. Name the button set variable mtest.

  5. Enter the following code as a procedure in the VALID code snippet of the button set:

          IF mtest=1
    
             SHOW GETS
          ELSE
             CLEAR READ
          ENDIF
    
    

  6. Click the List Box tool. In the List dialog box, type "mpoparray" (without the quotation marks) in the From Array box, and then assign the list box the variable name mpopval.

  7. Under Clauses, choose the "# Of Elements" button. In the resulting dialog box, select Expression, and then type the following:

          _TALLY
    

  8. From the Screen menu, choose Layout, choose the Code button, and then choose the "On Refresh (Show Gets)" button. In the resulting dialog box, enter the following code as a procedure:

          IF NOT EMPTY(mpopval)
    
             DELETE FOR name=mpopval
             * If you are designing a network application, the SELECT-SQL
             * should be modified as below so that the PACK is NOT necessary.
             PACK
          ENDIF
          SELECT name FROM employee INTO ARRAY mpoparray
    
          * The following variant might be used in a multiuser application:
          SELECT name FROM employee ;
             INTO ARRAY mpoparray WHERE NOT DELETED()
    
    
This code will prevent you from seeing any extraneous data. For example, when the last array element is deleted, a .F. might appear in the list; this code fragment prevents this from happening.

FoxPro for MS-DOS

  1. Start FoxPro for MS-DOS. From the File menu, choose New, select Screen, and then choose OK.

  2. From the Screen menu, choose Screen Layout.

  3. Under Screen Code, select Setup, and then choose OK. In the "UNTITLED Setup" window, type the following code:

          SET SAFETY OFF
          CREATE TABLE employee ;
    
             (name C(20),addr C(30),city C(30),zip C(5),;
             salary N(8,2),comments m)
          SET SAFETY ON
          INSERT INTO employee (name) VALUE ('Emp1')
          INSERT INTO employee (name) VALUE ('Emp2')
          INSERT INTO employee (name) VALUE ('Emp3')
          INSERT INTO employee (name) VALUE ('Emp4')
          INSERT INTO employee (name) VALUE ('Emp5')
          SELECT name FROM employee INTO ARRAY mpoparray
          mpopval=''     && two single quotation marks
    
       NOTE: The SELECT-SQL command yields the array (mpoparray) that will be
       used in the popup you will define in step 6. The mpopval variable will
       also be used by this popup.
    
       When you have finished typing the code, close the "UNTITLED Setup"
       window.
    
    

  4. From the Screen menu, choose Push Button. Create a button set with two prompts: The first button will perform the action; the second will terminate the READ. Name the button set variable mtest.

  5. Enter the following code as a procedure in the VALID code snippet of the button set:

          IF mtest=1
    
             SHOW GETS
          ELSE
             CLEAR READ
          ENDIF
    
    

  6. From the Screen menu, choose Popup, select Array Popup, and then type "mpoparray" in the Array Popup box.

  7. Assign the popup the variable name mpopval, and then select the "# Elements" box under Options. In the resulting dialog box, select Expression, and then type the following:

          _TALLY
    

  8. From the Screen menu, choose Screen Layout. Under READ Clauses, select Show. In the resulting dialog box, enter the following code as a procedure:

          IF NOT EMPTY(mpopval)
    
             DELETE FOR name=mpopval
             * If you are designing a network application, the SELECT-SQL
             * should be modified as below so that the PACK is NOT necessary.
             PACK
          ENDIF
          SELECT name FROM employee INTO ARRAY mpoparray
    
          * The following variant might be used in a multiuser application:
          SELECT name FROM employee ;
             INTO ARRAY mpoparray WHERE NOT DELETED()
    
    
This code will prevent you from seeing any extraneous data. For example, when the last array element is deleted, a .F. might appear in the list; this code fragment prevents this from happening.

REFERENCES

Information and code provided by John W. Stepp.


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.50c 2.60
KBCategory: kbprg kbprb
KBSubcategory: FxprgMultiuser


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: February 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.