Use of *# USERPOSTCOMMAND Screen Generator Directive

ID: Q112473

2.60 | 2.60 MS-DOS | WINDOWS kbtool

The information in this article applies to:

SUMMARY

FoxPro version 2.6 contains a new screen generator directive, *# USERPOSTCOMMAND, which expands the functionality of the Screen Builder. This new directive allows the use of code that is executed after GET fields are initially defined but before the READ is executed.

MORE INFORMATION

The *# USERPOSTCOMMAND directive is placed in the comment snippet of a GET field as follows:

   *# USERPOSTCOMMAND DO myprocedure

In this example, a line of code ("DO myprocedure") is inserted immediately after the GET field in the generated .SPR program.

You can use this directive to define a number of GET fields based on conditions that exist when the screen is initially executed. This approach is often more desirable than disabling GET fields when certain users should not have access to confidential information, such as salary figures.

NOTE: This directive will not override the limitation of being unable to define new GET fields within the active READ. It will not allow the current GET to be redefined at run time, since the code is placed on the line following the @ ... GET statement.

Example

1. Issue the following commands in the Command window:

      USE tutorial\customer
      CREATE SCREEN postcmd

2. Place two fields, CNO and COMPANY, near the top of the screen. Leave a
   number of blank lines in the window, so that line 7 is blank.

3. In the Setup snippet, add the following code:

      #SECTION 1
      PARAMETER security

4. In the comment snippet of the second GET field, add the following line:

      *# USERPOSTCOMMAND do moreflds with security

5. In the Cleanup snippet of the screen, add the following code:

      PROCEDURE moreflds
      PARAMETER level
      IF level = 1
         RETURN
      ELSE
         @ 7,20 SAY "YTD Purchased " GET ytdpurch
      ENDIF

6. Save and generate the screen.

7. In the Command window, issue the following command. This example is hard-

   coding a security level in the Command window; normally, such a
   parameter would be defined programmatically.

      DO postcmd.spr WITH 1

   The screen will appear with two GET fields.

8. Close the screen program. In the Command window, issue the following
   command:

      DO postcmd.spr WITH 2

The screen will appear with three GET fields.

Additional reference words: FoxDos FoxWin 2.60 KBCategory: kbtool KBSubcategory: FxtoolSbuilder

Keywords          : FxtoolSbuilder 
Version           : 2.60   | 2.60
Platform          : MS-DOS WINDOWS

Last Reviewed: May 1, 1996