Consultor Eletrônico



Kbase P3427: To Display Ampersand & in Variable with VIEW-AS TEXT Use &&
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

GOAL:

How To Display Ampersand & in Variable with VIEW-AS TEXT Use &&

FIX:

If you define a variable with VIEW-AS TEXT and you want to display an ampersand in the text, it is necessary to use && in the string which you assign to that variable.

To see this behavior, first run the following:

def var x as char format "X(20)" init "peaches && cream".
display x.

Then for comparison run the following:

def var x as char format "X(20)" init "peaches & cream".
display x.

In the first case the output will be "peaches & cream", in the
second case the output will be "peaches _cream". In the second
case, the & is treated as indication of an accelerator key for the
text, displayed as "_c" in "_cream".

The theory behind the way PROGRESS works in this regard is that
VIEW-AS TEXT is designed to be used to specify constants. The
assumption is that these variables will never be UPDATEd, and
furthermore, that these variables may some day be used as field
labels or button labels, both of which support accelerator
functionality. Given that, the & character in a VIEW-AS TEXT
variable is interpreted as an indicator of an accelerator.

FIX:

An alternative way to display non-updateable text with an embedded ampersand is to create a FILL-IN widget with the NO-LABEL attribute set to True and the ENABLED attribute set to False, then assign the desired string to the FILL-IN's SCREEN-VALUE attribute, e.g., "peaches & cream". The appearance of the widget will be the same as a TEXT widget, and the user will not be able to modify the FILL-IN's value.