start_list function call. The function syntax is as follows:
A dialog box list operation always begins with a(start_list key [operation [index]])
key argument is a string that identifies the dialog box tile. The key argument is case-sensitive. The operation argument is an integer value that indicates whether you are creating a new list, changing a list, or appending to a list. The following are valid operation arguments:
TheOperation codes for start_list |
|
---|---|
Value |
Description |
1 |
Change selected list contents |
2 |
Append new list entry |
3 |
Delete old list and create new list (the default) |
index argument is only used in change operations. The index indicates the list item to change by a subsequent add_list call. The first item in a list is index 0.
Theoperation, it defaults to 3 (create a new list). If you do not specify an index, the index value defaults to 0.
If you don't specifyYou implement the list operations as follows:
start_list call, call add_list repeatedly to add new items to the list. End list handling by calling end_list.
After thestart_list, call add_list once to replace the item whose index was specified in the start_list call. (If you call add_list more than once, it replaces the same item again.) End list handling by calling end_list.
After callingstart_list, call add_list to append an item to the end of the list. If you continue to call add_list, more items are appended until you call end_list.
After callingstart_list, then add_list (possibly more than once), and then end_list.
Regardless of which list operation you are doing, you must call the three functions in sequence:mapcar function is useful for turning a “raw” AutoLISP list into a list box display. In the following example, the appnames list contains strings that you want to appear in a list box called selections. You can use this code fragment to set up the list and display it as follows:
The(start_list "selections") ;Specify the name of the list box.
(mapcar ' add_list appnames) ;Specify the AutoLISP list.
(end_list)
Because list creation (3) is the default, this example doesn't specify it.
list_box tile is the index of the selected item (or the indexes of selected items, if multiple selections are allowed). If your program needs to know the actual text associated with an index, it must save the original list. It must also track changes to the list.
The value of aappnames has 12 items in it, and you want to append another list, called newnames, you could use the following code:
Appending list items is similar to creating a new list. If, for example,(start_list "selections" 2)
(mapcar 'add_list newnames)
(end_list)
add_list call. In this case, you specify the index of the item to change:
Changing a single item requires only one(start_list "selections" 1 5) ;Change the sixth item in the list.
(add_list "SURPRISE!") ;Remember that the first index is 0.
(end_list)
You cannot delete a list item or insert an item without rebuilding the list from scratch.