Thanks you all guys
the final working code drived from your comments
- (defun getDiaVal(/ fname lname age dialogLoaded dialogShow dcl_id) ;define defult value for text box (setq fname "first name" lname "last name" age "0" dialogLoaded T dialogShow T) ;; Load the DCL file. (if (= -1 (setq dcl_id (load_dialog "simple.dcl"))) (progn ;; There's a problem - display a message and set the ;; dialogLoaded flag to nil (princ "\nERROR: Cannot load simple_dcl.dcl") (setq dialogLoaded nil) ) ;_ end of progn ) ;_ end of if ;; Load the dialog box (if (and dialogLoaded (not (new_dialog "simple_dcl" dcl_id)) ) ;_ end of and (progn ;; There's a problem... (princ "\nERROR: Cannot show dialog gp_mainDialog") (setq dialogShow nil) ) ;_ end of progn ) ;_ end of if ;initilizing defualt values (if (and dialogLoaded dialogShow) (progn ;; Set the initial state of the tiles (set_tile "fname" fname) (set_tile "lname" lname) (set_tile "age" age) ) ) ;assign action to tiles (action_tile "cancel" "(done_dialog) (setq UserClick nil)") (action_tile"accept"(strcat "(progn (setq fname (get_tile "fname"))" "(setq lname (get_tile "lname"))" "(setq age (get_tile "age"))" "(done_dialog) (setq UserClick T))") ;_ end of strcat ) ;_ end of action tile ;; invoke the dialog. (start_dialog) ;; OK or cancel has been hit, you're out of the dialog. Unload it (unload_dialog dcl_id) ;; Build the resulting data (if UserClick (progn (setq Result (list (cons 42 fname) (cons 43 lname) (cons 3 age) ) ;_ end of list ) ;_ end of setq) ;_ end of progn ) ;_ end of if Result ) (defun C:Test(/ fname lname age dialogLoaded dialogShow dcl_id ) ;; extract the values (setq diare (getDiaVal)) (setq fname (cdr (assoc 42 diare)) lname (cdr (assoc 43 diare)) age (cdr (assoc 3 diare)) )(alert (strcat "your first name is " fname "," "your last name is " lname "," "your age is " age "." )) )
- simple_dcl : dialog { label = "My First DCL"; initial_focus = "fname"; spacer; : row { fixed_width = true; : column { width = 30; fixed_width = true; spacer; : text { label = "First Name"; } } : edit_box { key = "fname"; edit_width = 20; fixed_width = true;} } : row { fixed_width = true; : column { width = 30; fixed_width = true; spacer; : text { label = "Last Name"; }} : edit_box { key = "lname"; edit_width = 20; fixed_width = true;} } : row { fixed_width = true; : column { width = 30; fixed_width = true; spacer; : text { label = "Age"; }} : edit_box { key = "age"; edit_width = 20; fixed_width = true;} }: row { : spacer { width = 1; } : button { label = "OK"; is_default = true; key = "accept"; width = 8; fixed_width = true; } : button { label = "Cancel"; is_cancel = true; key = "cancel"; width = 8; fixed_width = true; } : spacer { width = 1;}}}
|