Donald,
I'd suggest that you gather all the info you need at once and stuff it into a list. For layer names, colors and ltypes it would read e.g. (("Layer1" 7 "Continuous")("Layer2" 3 "Dashed") ... )
Here's a small dialog and the code to illustrate:
// layerExample
layerDlg : dialog {
: column {
: list_box {
key = "layernames";
height = 12;
width = 30;
}
: row {
: text {
label = "Color:";
}
: text {
key = "color";
}
: image {
key = "showcolor";
fixed_width = true;
width = 2;
aspect_ratio = 1.0;
color = -15;
}
: spacer_1 {}
}
: row {
: text {
label = "LType:";
}
: text {
key = "ltype";
width = 20;
}
}
}
ok_only;
}
;; layerExample.lsp
;; Just a small utility to fill color into an image
;; tile. If color is 9, draw a black frame to prevent
;; it from blending into dialog background color
(defun fillColor (tile col / x y)
(setq x (dimx_tile tile)
y (dimy_tile tile))
(and (not col)(setq col -15))
(start_image tile)
(cond ((/= col 9)
(fill_image 0 0 x y col))
((= col 9)
(fill_image 0 0 x y 0)
(fill_image 1 1 (- x 2) (- y 2) col))
)
(end_image)
)
(defun C:ShowLayers (/ laylist layer dcl_id showInfo)
;; ShowInfo takes care of extracting info from the
;; selected layers sublist and showing the stuff
(defun showInfo (index lst / layerInfo color)
(setq layerInfo (nth (atoi index) lst)
color (cond ((nth (1- (cadr layerInfo))
'("red" "yellow" "green" "cyan" "blue" "magenta" "white")
)
)
((itoa (cadr layerInfo)))
)
)
(set_tile "color" color)
(fillColor "showcolor" (cadr layerInfo))
(set_tile "ltype" (caddr layerInfo))
(princ)
)
;; main routine
;; Get all layers with their colors and ltypes, and stuff
;; it all into one list
(while (setq layer (tblnext "LAYER" (not layer)))
;; insert code here to weed out xref layers and such
(setq laylist (cons (list (cdr (assoc 2 layer))
(abs (cdr (assoc 62 layer)))
(cdr (assoc 6 layer))
)
laylist
)
)
)
;; Insert code to sort list here. In this example, we'll
;; just reverse the list.
(setq laylist (reverse laylist)
dcl_id (load_dialog "layerexample.dcl"))
(cond ((new_dialog "layerDlg" dcl_id)
(start_list "layernames")
;; fill list_box with car values only (i.e. layer names)
(mapcar 'add_list (mapcar 'car laylist))
(end_list)
(action_tile "layernames" "(showInfo $value laylist)")
(start_dialog)
)
)
)