AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.03.2007, 17:40   #1  
IvanS is offline
IvanS
Участник
Аватар для IvanS
 
241 / 44 (2) +++
Регистрация: 30.06.2006
Адрес: Екатеринбург
Объект List
Скажите пожалуйста, как добавлять элементы в объект list и что делают методы AddStart и AddEnd?
P.S. нужно сохранить наименование чтобы их потом просматривать, для этого и был выбран данный объект.
Старый 05.03.2007, 17:48   #2  
kashperuk is offline
kashperuk
Участник
Аватар для kashperuk
MCBMSS
Соотечественники
Сотрудники Microsoft Dynamics
Лучший по профессии 2017
Лучший по профессии 2015
Лучший по профессии 2014
Лучший по профессии 2011
Лучший по профессии 2009
 
4,361 / 2084 (78) +++++++++
Регистрация: 30.05.2004
Адрес: Atlanta, GA, USA
Вот из Foundation Classes for DAX 2.5
Цитата:
Lists are structures that may contain any number of elements that are accessed sequentially. Lists may contain values of any X++ type. All the values in the list must be of the same type, given in the creation of the list. The implementation of lists is such that traversal of the list elements is very fast.
Lists may be traversed using the listIterator class, q.v.
Example
{
// Create a list of integers
list il = new list(types::integer);

// Add some elements to the list
il.addEnd(1);
il.addEnd(2);
il.addStart(3);

// Print the list
print il.toString();
print il.definitionString();
pause;
}

The following methods are available on list objects:
public new (types type)
Creates a list containing elements of the given type.
public boolean empty()
Returns TRUE if the list is empty i.e. if it does not contain any elements, and FALSE otherwise. This is equivalent to (elements() == 0)
public int elements()
Returns the number of elements in the list.
public any addStart(any value)
Add the given value to the start of the list. The element becomes the first element in the list. The value inserted is returned.
public any addEnd(any value)
Add the given value to the end of the list. The element becomes the last element in the list. The value inserted is returned.
public boolean equalTo (list l)
Returns TRUE if the given list is identical to the list on which the method is called and FALSE otherwise. Two lists are equal to another list if the two lists contain the same number of elements and the elements occur in the same order. This is a shorthand for using the static equal method: equal(this, l).
public int typeId()
Returns the type of the values in the list.
container pack()
Packs the list into a container, suitable for saving in a database etc. If the elements are objects, the pack method is called on each object to yield a (sub) container.
public str toString()
Returns a human readable form of the list, e.g <”Peter”, “Paul”, “Mary”>
public str definitionString()
Returns a string containing the definition of the list, e.g. “list of int”.
public static list merge (list l1, list l2)
Returns a list formed by appending the list l2 onto the list l1. The types of the lists must be the same.
public static boolean equal(list l1, list l2)
Returns TRUE if the two given lists are identical. Two lists are equal to another list if the two lists contain the same number of elements and the elements occur in the same order.
public static list create(container c)
Create the list from the container obtained from a prior call to pack, q.v.
2.2 ListIterators
List iterators are used to iterate over the elements in a list. They may be viewed as simply pointers into the lists over which they iterate. Functionality is available to start the iteratation, to determine whether or not more elements are available and to fetch the element pointed to by the iterator.
The order in which the elements occur during iteration is defined by the sequence in which the elements are inserted using the addStart and addEnd methods.
ListIterators and the lists over which they iterate must be on the same Client/Server side.
Example
{
list il = new list(types::integer);
listIterator it;

// Add some elements into the list...
il.addStart(1);
il.addStart(2);
il.addStart(4);

// Create a list iterator
it = new listIterator (il);

print it.definitionString(); // prints “int list iterator”
print it.toString(); // prints “(begin)[4]”

// Go on for as long as elements are found in the list...
while (it.more())
{
// fetch the next element
print it.value(); // prints 4 2 1
it.next();
}
print it.toString(); // prints (end)
pause;
}

The following methods are available on list iterator objects
public new (set s)
Create a new iterator for the given list. The iterator is positioned at the first value in the list, if the list is nonempty.
public any value()
Returns the value denoted by the iterator. It is an error to attempt to retrieve the value of an iterator that does not point to anything (i.e where more() returns FALSE).
public boolean more()
Returns TRUE if more elements are available in the list and FALSE otherwise. It is an error to access the elements pointed to by an iterator when this function returns FALSE.
public void next()
Moves the iterator to the next element.
public void begin()
Moves the iterator to the start of the list.
public void end()
Moves the iterator past the last element in the list. After executing this function more() will return FALSE.
public void delete()
Removes the element pointed to by the iterator from the list. The iterator will point to the next element.
public str toString()
Returns a textual representation of the iterator. If the iterator points to the first element in the set, the string will contain an indication of this, in the form:
“(begin)[value]”
If the iterator does not point to an element (i.e more() returns FALSE), the string returned is:
“(end)”
If the iterator points to a value the string is:
“[value]”
where value is a string representation of the element value.
public str definitionString()
Returns a textual representation of the type of the iterator, e.g. “int list iterator”
Теги
ax2.5

 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
AX UK: Draft Microsoft Dynamics AX 2009 Price List now Available Blog bot DAX Blogs 0 04.03.2008 06:13
Khue Trinh: Example of using a list Blog bot DAX Blogs 0 25.01.2008 17:10
Kashperuk Ivan: List panels in Dynaics AX - a short description of SysListPanel class Blog bot DAX Blogs 1 21.10.2007 22:51
casperkamal: Creating custom Picking list in Dynamics - Part II Blog bot DAX Blogs 0 22.03.2007 21:41
casperkamal: Creating a Custom Display List - Blog bot DAX Blogs 0 27.12.2006 17:20

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:50.