AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Here's how to design and code a Popup Listbox in DCL :

//DCL CODING STARTS HERE
popup : dialog {
label = "AfraLisp Popup List" ;

: popup_list {
label = "Choose Name:";
key = "selections";
value = "5" ;
edit_width = 12;
}

ok_cancel ;

}
//DCL CODING ENDS HERE

--------------------------------------------
Save this as "Popup.dcl"

Now the AutoLisp Coding

;AUTOLISP CODING STARTS HERE
(defun C:popup ()
;define function

(setq NAMES '("Monday" "Tuesday" "Wednesday" "Thursday"
"Friday" "Saturday" "Sunday")
);setq
;define list

(setq dcl_id (load_dialog "popup.dcl"))
;load dialog

(if (not (new_dialog "popup" dcl_id)
;test for dialog

);not

(exit)
;exit if no dialog

);if

(start_list "selections")
;start the list box

(mapcar 'add_list NAMES)
;fill the list box

(end_list)
;end list

(action_tile
"accept"
;if O.K. pressed

(strcat
;string 'em together
"(progn

(setq SIZ (atof (get_tile \"selections\")))"
;get list selection

"(done_dialog) (setq userclick T))"
;close dialog

);strcat

);action tile

(action_tile
"cancel"
;if cancel button pressed

"(done_dialog) (setq userclick nil)"
;close dialog

);action_tile

(start_dialog)
;start dialog

(unload_dialog dcl_id)
;unload

(if userclick
;check O.K. was selected

(progn
;if it was do the following

(setq SIZ (fix SIZ))
;convert to integer

(setq SIZ (nth SIZ NAMES))
;get the Day

(alert (strcat "You Selected: " SIZ))
;display the Day

);progn

);if userclick

(princ)

);defun

(princ)
;AUTOLISP CODING ENDS HERE

-----------------------------------------------------
Save this as "Popup.lsp"

Load and Run. Select a day from the Popup Listbox.
It should be displayed.
I have not declared any variables to allow you to view them.

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website