Consultor Eletrônico



Kbase P100305: How to list all the names and lengths of all character fields in a record?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/01/2005
Status: Unverified

GOAL:

How to list all the names and lengths of all character fields in a record?

FIX:

The following code lists the names, formats and lengths of all the character fields in the first customer record:
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE bh AS HANDLE NO-UNDO.
DEFINE VARIABLE fh AS HANDLE NO-UNDO.
FUNCTION getLength RETURNS INTEGER (INPUT ph AS HANDLE).
RETURN LENGTH(ph:BUFFER-VALUE).
END.
bh = BUFFER Customer:HANDLE.
FIND FIRST customer.
DO i = 1 TO bh:NUM-FIELDS:
fh = bh:BUFFER-FIELD(i).
IF fh:DATA-TYPE = "CHARACTER" THEN
DISPLAY
fh:NAME FORMAT "X(15)"
fh:FORMAT FORMAT "X(10)"
getLength(fh) FORMAT "ZZZ"
WITH FRAME a DOWN.
DOWN WITH FRAME a.
END.