Use of *# USERPOSTCOMMAND Screen Generator Directive

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

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


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.