PRB: Ampersand Displays as Underscore in PopupLast reviewed: November 17, 1997Article ID: Q101594 |
The information in this article applies to:
SYMPTOMSAfter you create a popup from an array that has strings as elements, if a element has an ampersand (&) in the string's text, the ampersand displays as "_" (an underscore) instead of "&" in the selected item box of the popup. For example, if the array element was "TEST1 & TEST2", it would display in the selected item box as "TEST1 _TEST2" when selected.
CAUSEThis behavior is caused by a feature of Windows. In Windows, an ampersand indicates that the next character should be underlined; therefore, this behavior also occurs in FoxPro for Windows. To display an ampersand in Windows, you have to use two ampersands (for example, && Text). However, this workaround cannot be used in FoxPro because a double ampersand indicates that the following text is a comment and FoxPro should ignore the rest of the line, which usually generates a syntax error.
RESOLUTIONThe best resolution for this is not to use ampersands in popups, whether from arrays or lists. The reason for this is that the behavior of some of the workarounds is unreliable and unpredictable. One workaround that could be acceptable for short popups is to create the popup from a list. To do this, initialize a variable in the Setup code for each item that needs to contain an ampersand, and then put the variable in the prompt for the popup using macro substitution. For example, in the Setup code, place this line of code:
myvar="TEST1 &"+"& TEST2"And in the popup prompt's list, enter the variable preceeded by an ampersand(for macro substitution)
&myvarItems in the list that do not contain ampersands do not need to be placed in variables. The problem with this resolution is that the items on the list show two ampersands, not just one. But the display value just shows one. Both ampersands get stored to the popup's variable. There is not a good solution for this issue if the popup is from an array and some of the array elements contain text with ampersands. Changing these elements as above can be tried.
MORE INFORMATION
Steps to Reproduce Problem
|
Additional reference words: FoxWin 2.60 2.0a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |