Question

This is a superfluous question. Is there any dynamic array or list in Progress 10.2B?

Example:

I create a base class called "InventoryTransaction". I read a MSSQL table from Progress and I would like to create an instance of InventoryTransaction class for each record found then add it to a "list/array" so I can later process them.

Is there something like MyArray:Add(MyItem) that will increase automatically the array size +1 then will add the instance of MyItem to the array?

I discovered the function EXTENT to set a size dynamically to an array but I do not know the count before reading all the transaction in the MSSQL table. Alternatively, I could execute a "select count(*) from MyTable" before reading all the transaction to retrieve the count and then extent the array.

Thank you! Happy friday! Sebastien

Était-ce utile?

La solution 3

The short answer is - no, the 10.2B AVM doesn't allow you to dynamically resize an array.

The long answer is you could (a) add the object to a linked list of objects, or (b) create a temp-table with a Progress.Lang.Object field, create a new TT record for each object instance you want to track, and assign the object's pointer to the TT's PLO field.

Autres conseils

You can create "indeterminate" arrays. i.e.

define variable x as decimal extent no-undo.

An indeterminate array variable can be in one of two states: fixed or unfixed, meaning it either has a fixed dimension or it does not. An indeterminate array variable has an unfixed dimension when first defined. You can fix the dimension of an indeterminate array variable by:

  • Initializing the array values when you define the variable,

  • Using the INITIAL option

  • Setting the number of elements in the array variable

  • Using the EXTENT statement

  • Assigning a determinate array to the indeterminate array, fixing it to the dimension of the determinate array

  • Passing array parameters to a procedure, user-defined function, or class-based method, so that the indeterminate array variable is the target for the passing of a determinate array, fixing the indeterminate array to the dimension of the determinate array

Once fixed, ABL treats a fixed indeterminate array as a determinate array.

I just discovered progress.lang.object:

FILE: array.p

/* declaration */
DEFINE TEMP-TABLE arrITem
    FIELD Item AS CLASS PROGRESS.lang.OBJECT.

DEFINE VARIABLE oItem AS CLASS Item NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.

/* create 10 products */

DO i = 1 TO 10:
    CREATE arrItem.
    arrItem.Item = NEW Item("Item_" + STRING(i), "Description_" + STRING(i)).
END.

/* display object information */
FOR EACH arrItem:
    ASSIGN oItem = CAST(arrItem.Item,Item).
    DISPLAY oItem:ItemNo.
END.

FILE: item.cls

CLASS Item:


    DEFINE PUBLIC PROPERTY ItemNo AS CHARACTER
        GET.
        SET.

    DEFINE PUBLIC PROPERTY DESCRIPTION AS CHARACTER
        GET.
        SET.

    /* constructor */  
    CONSTRUCTOR PUBLIC Item():
    END.

    CONSTRUCTOR PUBLIC Item(
        INPUT strItemNo AS CHARACTER
       ,INPUT strDescription AS CHARACTER
        ):

        ASSIGN ItemNo = strItemNo.
        ASSIGN DESCRIPTION = strDescription.
    END.

END CLASS.

Thank you! Sebastien

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top