Tharwat Posted April 14, 2012 Posted April 14, 2012 Hello Is there any example of how to activate and deactivate the popup list when checking the a toggle box ? Things like the one in Plot dialog . (when toggle "Fit to paper" is being checked , the "Scale" Popup list would be deactivated and Vice versa . Quote
Lee Mac Posted April 14, 2012 Posted April 14, 2012 If you are referring to Standard DCL: use a mode_tile expression acting on the popup_list tile, in the action_tile statement for the toggle tile. Quote
pBe Posted April 15, 2012 Posted April 15, 2012 Sample: (defun c:test ( / sampdcl val) (setq sampdcl (load_dialog "plotsample.dcl")) (if (not (new_dialog "plotsample" sampdcl)) (exit) ) (start_list "lst")(mapcar 'add_list '("1:10" "1:20" "1:50"))(end_list) (start_list "UNIT:")(mapcar 'add_list '("mm" "inches"))(end_list) ([color=blue]action_tile[/color] "FTP" "(setq val $value)([color=blue]mode_tile[/color] \"lst\" (boole 1 (atoi val))) ([color=blue]mode_tile[/color] \"UNIT:\" (boole 1 (atoi val)))") (action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)" ) (start_dialog) (unload_dialog sampdcl) ) plotsample : dialog { label = "Try me...."; : boxed_column { : [color=blue]toggle[/color] { label = "F&it to paper"; key = "FTP"; } : [color=blue]popup_list[/color] { label = "&Scale:"; key = "lst"; width = 25; } : [color=blue]popup_list[/color] { key = "UNIT:"; alignment = right; width = 10; fixed_width = true;} } ok_cancel ; } Quote
Tharwat Posted April 15, 2012 Author Posted April 15, 2012 Thanks Lee for the info. Thanks pBe for the perfect example , it works great . Could we have the same trick if a specific item being selected from a popup list ? Thank you so much Quote
pBe Posted April 15, 2012 Posted April 15, 2012 (edited) It would be the Same approach tharwat. ex. (setq lst_ '("mm" "inches")) (action_tile "LstKey" (vl-prin1-to-string (quote (progn (setq val2 (nth (atoi (get_tile $key)) lst_)) (mode_tile "key" (if (member val2 '("mm" "cm" "m")) 1 0)) ) ) ) I'm sure you'll figure out what that snippet is all about. BTW: the previous code is NOT a perfect example BUT one of the many ways to approach it. Here, I tested it for you (defun c:test ( / sampdcl val) [color=blue](setq lst_ '("1:10" "1:20" "1:50" "1:60")) [/color](setq sampdcl (load_dialog "plotsample.dcl")) (if (not (new_dialog "plotsample" sampdcl)) (exit) ) (start_list "lst")(mapcar 'add_list [color=blue]lst_[/color])(end_list) (start_list "UNIT:")(mapcar 'add_list '("mm" "inches"))(end_list) (action_tile "FTP" "(setq val $value)(mode_tile \"lst\" (boole 1 (atoi val))) (mode_tile \"UNIT:\" (boole 1 (atoi val)))") [color=blue](action_tile "lst" (vl-prin1-to-string (quote (progn (setq val2 (nth (atoi (get_tile $key)) lst_)) (mode_tile "UNIT:" (if (member val2 '("1:20" "1:60")) 1 0)) ))) )[/color][color=blue] [/color](action_tile "accept" "(done_dialog 1)") (action_tile "cancel" "(done_dialog 0)" ) (start_dialog) (unload_dialog sampdcl) ) Edited April 15, 2012 by pBe Quote
Tharwat Posted April 15, 2012 Author Posted April 15, 2012 That's a very great work indeed , and it is very kind of you to do all that for me . I have to play with it a little bit to suit my needs . Thank you so much . Quote
pBe Posted April 16, 2012 Posted April 16, 2012 That's a very great work indeed , and it is very kind of you to do all that for me . I have to play with it a little bit to suit my needs . Thank you so much . You're welcome tharwat Glad you find the examples useful. Cheers. Quote
Tharwat Posted April 16, 2012 Author Posted April 16, 2012 Hi pBe . Did you notice when checking the code in Vlisp it throw an error ... ? is this normal ? [CHECKING TEXT loading...] . ; warning: too few arguments: (BOOLE 1 (ATOI VAL)) ; warning: too few arguments: (BOOLE 1 (ATOI VAL)) ; === Top statistic: ; Global variables: ($VALUE VAL) ; Function definition (with number of arguments): ((C:TEST . 0)) ; Check done. Quote
pBe Posted April 17, 2012 Posted April 17, 2012 Hi pBe .Did you notice when checking the code in Vlisp it throw an error ... ? is this normal ? I dont really know what constitutes "normal". Anyhoo if you add another argument on the boole function line that error message will go away. (action_tile "FTP" "(setq val $value)(mode_tile \"lst\" (boole 1 [b][color=blue]1 [/color][/b](atoi val))) (mode_tile \"UNIT:\" (boole 1 [b][color=blue]1[/color] [/b] (atoi val)))") Come to think of it, the help file does say Note that Boole will accept a single integer argument, but the result is unpredictable I never notice that until now. Good catch Tharwat. Cheers Quote
Tharwat Posted April 17, 2012 Author Posted April 17, 2012 Anyhoo if you add another argument on the boole function line that error message will go away. Exactly . what 's what happened and solved it . Thanks a lot . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.