Consultor Eletrônico



Kbase 19875: ADM2 - How to Simulate an Attribute List for SmartObjects in
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/19/2008
Status: Verified

GOAL:

This solution explains the difference in defining an attribute list
to a SmartObject between Progress Version 8.x and Version 9.x.

FACT(s) (Environment):

Progress 9.x

FIX:

In Version 8.x you can define an attribute list to a SmartObject at the same time with the following method;

RUN set-attribute-list ("firstName=John,lastName=Smith").

Or by using variables with the same instruction:

DEFINE VARIABLE cFirstNam AS CHARACTER NO-UNDO.
DEFINE VARIABLE cLastNam AS CHARACTER NO-UNDO.

ASSIGN cFirstNam = "John"
cLastNam = "Smith".

RUN set-attribute-list ("firstName=" + cFirstNam + ",lastName=" +
cLastNam).

In Version 9.x, however, the attributes are replaced by properties. In order to define a property in a SmartObject use the following function:

DYNAMIC-FUNCTION('setUserProperty':U,
INPUT pcPropName /* CHARACTER */,
INPUT pcPropValue /* CHARACTER */).

To get the value of a property use the following function:

DYNAMIC-FUNCTION('getUserProperty':U,
INPUT pcPropName /* CHARACTER */).

When you need to define several properties in Version 9.x, use the
function 'setUserProperty' as many times as the number of properties
you want to define in a SmartObject.
The following example shows how to use functions for setting and
getting several properties on a SDB in a SmartWindows. Take these
steps:

1) Define a property on a SmartDataBrowser. The name of the
property must be: 'All'.

ON CHOOSE OF setProperty IN FRAME fMain /* Set Property in
SmartWindows*/
DO:
DYNAMIC-FUNCTION('setUserProperty':U IN h_btablewi,
INPUT "ALL",
INPUT "firstName=John,lastName=Smith").
END.


2) Read the property value of a SmartBrowse. This function should
be in a structured include file.

FUNCTION getProperty RETURNS CHARACTER
( cPropertyName AS CHARACTER ) :
/*--------------------------------------------------------------------
Purpose:
Notes:
--------------------------------------------------------------------*/
DEFINE VARIABLE cProprtys AS CHARACTER NO-UNDO.
DEFINE VARIABLE cProprty AS CHARACTER NO-UNDO.
DEFINE VARIABLE iProprtys AS INTEGER NO-UNDO.

ASSIGN cProprtys = DYNAMIC-FUNCTION('getUserProperty':U, INPUT "ALL").

IF cProprtys = ? OR cProprtys = "" THEN RETURN ?.

REPEAT iProprtys = 1 TO NUM-ENTRIES(cProprtys):

ASSIGN cProprty = ENTRY(iProprtys, cProprtys).

IF ENTRY(1, cProprty, "=") = cPropertyName
THEN RETURN ENTRY(2, cProprty, "=").

END. /*REPEAT iProprtys = 1 TO NUM-ENTRIES(cProprtys)*/

RETURN ?.

END FUNCTION.