How to Create a Screen with a User-Defined Title

Last reviewed: April 29, 1996
Article ID: Q105280
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a
  • Microsoft FoxPro for Windows, version 2.5 and 2.5a

SUMMARY

It is sometimes desirable to allow the user to specify a title for a screen using variables or other hard-coded values. You can do this by using generator directives in the screen setup code, as described below.

MORE INFORMATION

FoxPro for Windows

  1. Create or modify an existing screen.

  2. From the Screen menu, choose Layout. In the Title box, type the variable for the title that will be passed into the screen. The syntax for the title is:

          ~ title1
    

    NOTE: A tilde (~) MUST be entered before the variable for the title.

  3. Choose the Code button. In the Screen Setup Code box, type the following code:

          #ITSEXPRESSION ~
          #SECTION1
          PARAMETER title1
          VARNAME=title1
    

  4. Generate the screen with the name SCREEN1.SPR.

  5. Run the screen by entering the following code in a program or in the Command window:

          title1=' My special screen title '
          DO Screen1.spr WITH title1
    

The screen will be displayed with whatever character expression is assigned to title1.

If you have a memory variable (numeric) with a value of 1027, and you try either of these methods, you will get the literal string of the tilde and the memvar, not the substitution. To display the title properly, do the following:

  1. In the Command window, type the following:

          USE tutorial\salesman
          CREATE SCREEN.
    

  2. From the Screen menu, choose Quick Screen.

  3. From the Screen menu, choose Layout. In the Name box, type "mytest" (without the quotation marks).

  4. In the Screen Layout dialog box, choose the Code button, and type the following in the Setup Code box:

          mydate=1027
          modify window mytest title 'Title is '+alltrim(str(mydate))
    

FoxPro for MS-DOS

  1. Create or modify an existing screen.

  2. From the Screen menu, choose Screen Layout, and select Window. In the Title box, enter the variable for the title that will be passed into the screen. The syntax for the title is:

          ~ title1
    

    NOTE: A tilde (~) MUST be entered before the variable for the title.

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

          #ITSEXPRESSION ~
          #SECTION1
          PARAMETER title1
          VARNAME=title1
    

  4. Generate the screen with the name SCREEN1.SPR.

  5. Run the screen by entering the following code in a program or in the Command window:

          title1=' My special screen title '
          DO Screen1.spr WITH title1
    

The screen will be displayed with whatever character expression is assigned to title1.

REFERENCES

"Developer's Guide," (MS-DOS), versions 2.0 and 2.5, pages D2-31 to D2-32

"Developer's Guide," (Windows), version 2.5, pages D2-38 to D2-40


Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a
KBCategory: kbenv kbprg kbui kbcode
KBSubcategory: FxenvMemory


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