Label control - Ampersand displayed as underscore

0 Likes

Problem:

When the ampersand ( & ) is displayed using the graphical label control, it is rendered as underscore ( _ ) which is not expected. This behavior occurred when converting a character-based screen to a simple graphical user interface (GUI) that utilizes labels and entry-fields.

Resolution:

ACUCOBOL-GT User Interface Programming

Version 8.0

Chapter 5: Control Types Reference > 5.12 Label >

5.12.1 Label: Common Properties

NO-KEY-LETTER

This style suppresses the interpretation of "&" as a key prefix. This is useful in cases where you are assigning user-entered data to a label and want to allow values that include the ampersand ("&") character (such as "AT&T").

Alternatively, and a bit more complicated, the data string can be parsed programmatically and when an ampersand is encountered the string can be modified to add a second ampersand, e.g.:

AT&T

to:

AT&&T

when the two ampersands are encountered together the runtime will interpret/display this as an ampersand instead of an underscore.

The second option may be of value when specifying NO-KEY-LETTER may not be appropriate ( when the & needs to be displayed as _ ).

Old KB# 2781
Comment List
Related
Recommended