List can be used to store a list of elements and this type is quite portable for quick manipulation.
You can either use ListEnumerator or ListIterator. These 2 classes are quite similar unless must use ListIterator if you want to delete an element in the list.
static void STU_List(Args _args)
{
List lst; //list
ListEnumerator lstEnum; //traverse through the elements in the list
CustTable custTable;
VendTable vendTable;
Common common;
int i;
;
lst = new List(Types::Record);
lstEnum = lst.getEnumerator();
lst.addEnd(CustTable::find("4000"));
lst.addEnd(VendTable::find("3000"));
lst.addStart(CustTable::find("4020"));
info(lst.toString());
info(lst.definitionString());
info(lstEnum.toString());
info(lstEnum.definitionString());
lstEnum.reset();
lstEnum.moveNext(); //must move next to get to the first
for(i=0; i<3; i++){
common = lstEnum.current();
if(common.TableId==tablenum(CustTable)){
custTable = lstEnum.current();
info(strFmt("%1, %2", custTable.AccountNum, custTable.Name));
}else if (common.TableId==tablenum(VendTable)){
vendTable = lstEnum.current();
info(strFmt("%1, %2", vendTable.AccountNum, vendTable.Name));
}
lstEnum.moveNext();
}
}
Result:
Message (04:27:17)
<Rec=<5637145460> CustTable, Rec=<5637145440> CustTable, Rec=<5637145455> VendTable>
List of record
Unknown
record list enumerator
4020, Inter Company
4000, Light and Design
3000, A. Datum Corporation
Leave a comment