Consultor Eletrônico



Kbase P117636: 4GL/ABL: How does the FORMAT phrase work?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/17/2011
Status: Verified

GOAL:

4GL/ABL: How does the FORMAT phrase work?

GOAL:

How does the OpenEdge Data Dictionary field FORMAT attribute work?

GOAL:

Does the FORMAT phrase count bytes, characters or columns?

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.x

FIX:

The OpenEdge Data Dictionary field FORMAT attribute and the 4GL/ABL FORMAT phrase specifies the display format in columns. For example, the character FORMAT ¡°x(8)¡± can accommodate the following:
1. Eight, one-column characters. One-column characters exist in single-byte, double-byte, or UTF-8 code pages.
2. Four, two-column characters. Two-column characters exist in double-byte and UTF-8 code pages.
3. Other combinations of one- and two-column characters totaling up to eight columns.
A possible solution to solving a problem whereby the field FORMAT contains a separator, such as "XX-XX", would be to use SUBSTRING when displaying the field instead of relying on the FORMAT phrase. This has the added benefit that it would work regardless of the number of bytes of each character. For example:

Example 1:
DEFINE VARIABLE myfield AS CHAR INIT "²âÊÔAB" NO-UNDO.
MESSAGE SUBSTRING(myfield,1,2) + "-" + SUBSTRING(myfield,3,2) VIEW-AS ALERT-BOX.

Example 2, using a FUNCTION to make it easier for multiple occurrences:
DEFINE VARIABLE myfield AS CHAR INIT "²âÊÔAB" NO-UNDO.
FUNCTION f2-2 RETURNS CHAR (INPUT inchar AS CHAR):
RETURN SUBSTRING(inchar,1,2) + "-" + SUBSTRING(inchar,3,2).
END.
MESSAGE f2-2(myfield) VIEW-AS ALERT-BOX.