Jump to content
Developer Wiki and Function Reference Links ×

Check Box


MaxStudio

Recommended Posts

Is there a way that I can get a check boxed to be selected when I select a specific pull down item?

At the moment I can only get the check box to be unchecked and then the user has to check it. I want the default (depending on the pulldown choice) to have the check box checked. Then the user could have the choice to uncheck the box.

Thanks

Link to comment

Not really sure, but it seems you'd have something somewhere that said:

If (pull-down choice) = (this or that) Then SetItem(check box identifier,True);

I'm guessing you have a Case Statement in a Dialog? This would be after the item number of the pull-down. The part where you reap the users choice and do something with it. Not that I've ever used a choice box myself...

You might have to post some code to get more help. Maybe even from someone who knows list boxes!

Charles

Link to comment

Tried to post this earlier, but the TechBoard was non-responsive.

Max,

???You can read your menu with: GetSelChoice(MenuID, 0, Mode, S);

and set (or clear) your check box with: SetItemEnable(CkBoxID, SomeBooleanValue);

???Are you using Modern Dialogs or Classic? The following was written assuming Modern Dialogs, but these two commands work in both.

Example:

{ In your dialog handler routine }

CONST

???MenuID = 20;

???ChkBx1 = 31;

???ChkBx2 = 32;

VAR

???MenuChoice :Integer;

???MenuString :String;

case item of

???SetupDialogC: begin

??????SetItemEnable(ChkBx1, True); { Starting value always checked }

??????GetSelChoice(MenuID, 0, MenuChoice, MenuString);

??????SetItemEnable(ChkBx2, (MenuChoice=1)); { Checked if Menu item is second in list (Modern Dialog), unchecked otherwise }

???end; ???{ Setup }

???{ item specific code goes below }

???MenuID: begin end;

???ChkBx1: begin end;

???ChkBx2: begin end;

end; { case }

Add similar code to your menu dialog item (20 in this example) to modify check boxes accordingly as things change.

Raymond Mullin

Vectorworks 2009 D/RW (User since MC+2.0)

Intel macMINI / OS 10.4.11

Link to comment

Hi Charles,

???Long time, no chat. As someone recently inquired of me, I hope you are in fine fettle.

What do you call (MenuChoice=1)..."boolean expression" or somesuch...

Yeah, I've gotten frugal with code in my old age. For simple expressions I often put them inline with the calling function. As long as the function doesn't return a value in that location you can do it this way.

This code snippet:

Boo := MenuChoice = 1;???{ Boo is TRUE if MenuChoice equals 1, FALSE otherwise }

SetItemEnable(ChkBx2, Boo);

is the same as:

SetItemEnable(ChkBx2, MenuChoice=1);

You'll also see some people write:

if (MenuChoice=1) then Boo := True

else Boo := False;

SetItemEnable(ChkBx2, Boo);

which also works and is very readable, but I tend to go for minimalism so I can see more code on one page. My scripts tend to be getting bigger so I'm trying to make them smaller every chance I get. The VS compiler is extremely robust and will handle a very complex expression without flinching.

Here's another favorite of mine that I've been using the last few years that replaces a simple IF/Then/Else statement with an inline expression.

function iif (A :Boolean; B, C :Integer) : Integer;???{ I got the function name from FoxBASE many years ago }

{ if A is true, return the value in B else return the value in C. }

Begin

???if A then iif := B else iif := C;

End;???{ iif }

With it you can say things like:

HorOffset := Xoriginal + iif(LeftView, X1, X2);

if LeftView is true, then HorOffset equals Xoriginal + X1

else HorOffset equals Xoriginal + X2

I also have iifr, iifs & iifv functions for Real, String and Vector expressions respectively.

Enjoy,

Raymond

Link to comment

A fine fettle indeed Raymond. Hope your fettle is good as well.

Haven't been scripting much lately though, aside from updating a few things in the transition to 2009 from 11.

Yeah, I like the minimal aspect. This inline expresion is very similar to using a function as a parameter instead of introducing another variable, assigning value and using that.

And thanks for iiiiif as well. Could be a huge IfThen killer for me. I have some that seem to go on forever.

Winter's coming on and that's the coding season for me.

Maybe I'll dream up a new tool that needs a list box of some sort.

See you around I hope.

Keep on lurking.

Link to comment

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