Jump to content

Recommended Posts

Posted

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 .

Image.jpg

Posted

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.

Posted

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

Posted

Thanks Lee for the info.

 

Thanks pBe for the perfect example , it works great . :thumbsup:

 

Could we have the same trick if a specific item being selected from a popup list ?

 

Thank you so much

Posted (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 by pBe
Posted

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 .:thumbsup:

Posted
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 .:thumbsup:

 

You're welcome tharwat :)

Glad you find the examples useful.

 

Cheers.

Posted

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.

Posted
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. :thumbsup:

 

Cheers

Posted

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 .:thumbsup:

 

Thanks a lot .

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...