PRB: How to Clear Popup Bars in a List Object

ID: Q117931

2.50 2.50a 2.50b 2.60 | 2.00 2.50 2.50a 2.50b 2.60 | 2.50b 2.50c

WINDOWS               | MS-DOS                     | MACINTOSH
kbprg kbprb

The information in this article applies to:

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

Keywords          : FxprgMultiuser 
Version           : 2.50 2.50a 2.50b 2.60 | 2.00 2.5
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: February 17, 1996