How to Modify GENSCRN.PRG to Refresh Text Field Labels

ID: Q119302

2.5x 2.60 | 2.5x 2.60

WINDOWS   | MS-DOS

The information in this article applies to:

SUMMARY

NOTE: Microsoft does not provide technical support for FoxPro tools such as GENSCRN.PRG after they have been modified from their original form.

In some cases, the text labels and refreshable SAY fields in the Screen Builder may need to be redisplayed, such as on a screen that was previously CLEARed. Text objects created in the Screen Builder are generated as SAY objects in the .SPR code. In order to refresh these field label SAYs as well as the output SAY fields, the @ ... SAY commands must be placed in the SHOW clause of the generated code. The example below shows how to modify GENSCRN to accept a custom generator directive which will force all text labels along with refreshed SAY field objects to be redisplayed.

NOTE: At least one SAY field must have the Refresh check box option marked in the Output Field dialog box of the Screen Builder so that its contents will reappear, as well as to trigger generation of the SHOW clause code.

MORE INFORMATION

 1. Copy the current GENSCRN.PRG file to another file. For example, type
    the following command at the MS-DOS command prompt in the main FoxPro
    directory:

       COPY GENSCRN.PRG SCRENGEN.PRG

 2. The newly created file should replace GENSCRN so that future updates
    will not overwrite changes, as well as to preserve a copy of the
    original file. In order for FoxPro to always use SCRENGEN instead of
    the original GENSCRN program, the _GENSCRN system variable must be
    changed to point to the custom program. If the CONFIG.FPW or CONFIG.FP
    file does not already exist, create it as an ASCII text file and type
    the following command in the file:

        _GENSCRN="C:\<FoxPro_directory>\SCRENGEN.FXP"

 3. Start FoxPro, and then issue the following command in the Command
    window:

        MODIFY COMMAND SCRENGEN

 4. In the editing window, press CTRL+F, type the following text to look
    for, and then choose the Find button or press CTRL+W:

        m.g_noreadp

 5. Add a new line below the "m.g_noreadplain = .F." line, and enter the
    following statement:

        m.g_saytext      = .F.    && custom flag to refresh text SAYs

    NOTE: Although it is not critical to align the text with the
    statements above it, readability will be maintained in doing so.

 6. Press CTRL+F, and find the following text:

       #READ"

    NOTE: Be sure to use a double quotation mark, not two single quotation
    marks.

 7. When you find the text, press the HOME key, copy the line (including
    the carriage return) by pressing SHIFT+END, SHIFT+RIGHT ARROW, and
    then CTRL+C. Press the DOWN ARROW key 17 times, and place the cursor
    in the home position on the line containing "ENDCASE".

 8. Press CTRL+V to paste in the new line, and change "READ" to "SAYT" and
    "READCLAUSES - Additional READ clauses" to "SAYTEXT - Custom
    directive".

 9. Insert a new line below the pasted line, and type:

       REPLACE ALL showtype WITH 1, refresh WITH .T. FOR objtype = 5

10. Insert another line, and type:

       m.g_saytext=.T.

   The additions in context should now appear as follows:

       .
       .
       .
            ENDIF
       CASE LEFT(m.upline,5)="#SAYT"    && #SAYTEXT - Custom directive
            REPLACE ALL showtype WITH 1, refresh WITH .T. FOR objtype = 5
            m.g_saytext = .T.
       ENDCASE
       .
       .
       .

11. Press CTRL+F, and find the following text:

       REFRESH =

   NOTE: Make sure you include the space before the equal sign.

12. Press the HOME, UP ARROW, UP ARROW, CTRL+RIGHT ARROW, and CTRL+RIGHT
   ARROW keys to move the cursor to the first parenthesis in the "SCAN FOR
   ((objtype = c_otfield ..." line, and then insert an additional left
   parenthesis, so that the first part of the line now reads:

       SCAN FOR (((objtype = c_otfield ...

13. Press CTRL+G and then press END to move to the end of the line, and add
   another right parenthesis, a space, and a semicolon, so that the line
   now reads:

       ... g_screens[m.g_thisscreen,7])) ;

14. Add a new line below this line, and enter the following:

       OR (objtype = 5 AND m.g_saytext)

15. Press CTRL+W to close and save the program. Compile the new program by
   choosing Compile from the Program menu, or by typing the following
   command in the Command window:

       COMPILE SCRENGEN.PRG

Now that the SCRENGEN.PRG program is in place, you can specify the option to refresh text field label SAYs by placing the custom generator directive #SAYTEXT in the Setup code of the appropriate screen. If the #SAYTEXT directive is not used, the screen will be generated normally.

Functionality

The memory variable m.g_saytext is used to determine whether to generate code to refresh all the SAYs found in the .SCX file. In order for SAYs to be refreshed, the same code used in the screen layout section of the generated code is repeated in the SHOW clause of the READ command. Normally, only SAY screen fields (objcode 15) that have the Refresh check box selected are generated in the SHOW clause during the PLACESAYS procedure within the screen generator. By adding the OR clause to include SAY objects (objcode 5) when m.g_saytext is .T., normal SAYs will also be placed in the SHOW routine.

However, to meet the other requirements imposed by the generator code, two values must be changed in the .SCX file so that the SAY objects will be included. The Showtype and Refresh fields are changed within the NOTEDIRECTIVES procedure whenever it detects that the #SAYTEXT directive is found in the Setup code of the current screen. (Changing the .SCX database for the SAYs will not affect their appearance within the Screen Builder during modification.) Additionally, the m.g_saytext memory variable is set to TRUE.

To further refine the scope of which normal SAY objects are included, this section of the generator program could be modified to accept parameters after the #SAYTEXT directive. For example, "#SAYTEXT 2,5,6-12" could indicate to refresh only objects 2 and 5 along with the range of objects 6 through 12. This would be determined by only replacing the Showtype and Refresh fields for these particular records, indicated by a further condition of the REPLACE ... FOR clause. The actual code to perform this restriction would vary, depending upon the chosen implementation of parameter representations.

Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b 2.60 blank empty "missing text" KBCategory: KBSubcategory: FxtoolSbuilder

Keywords          : kbcode FxtoolSbuilder 
Version           : 2.5x 2.60 | 2.5x 2.60
Platform          : MS-DOS WINDOWS

Last Reviewed: May 22, 1998