AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Would you like a dialog complete with slider?
I thought you would.....

//DCL CODING STARTS HERE
slide : dialog {
label = "Slider Example" ;

: edit_box {
key = "eb1" ;
label = "Slot &Length (O/All Slot)" ;
edit_width = 6 ;
}

: slider {
key = "myslider" ;
max_value = 100;
min_value = 0;
value = "50";
}

ok_cancel ;

}
//DCL CODING ENDS HERE

Save this as "Slide.dcl". Now the AutoLisp Coding :

;CODING STARTS HERE
(defun C:Slide ()
;define function

(setq lngth 50.0)
;preset slot length

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

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

);not

(exit)
;exit if no dialog

);if

(set_tile "eb1" "50")
;put data into edit box

(mode_tile "eb1" 2)
;switch focus to edit box

(action_tile "myslider"
;if user moves slider

"(slider_action $value $reason)")
;pass arguments to slider_action

(action_tile "eb1"
;if user enters slot length

"(ebox_action $value $reason)")
;pass arguments to ebox_action

(defun slider_action (val why)
;define function

(if (or (= why 2) (= why 1))
;check values

(set_tile "eb1" val)))
;update edit box

(defun ebox_action (val why)
;define function

(if (or (= why 2) (= why 1))
;check values

(set_tile "myslider" val)))
;update slider

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

(strcat
;string 'em together

"(progn

(setq lngth (get_tile \"eb1\"))"
;get slot length

"(done_dialog)(setq userclick T))"
;close dialog, set flag

);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

(alert (strcat "You Selected: " lngth))
;display the selected length.

);if userclick

(princ)

);defun

(princ)
;AUTOLISP CODING ENDS HERE

Save this as "Slide.lsp".

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