Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: dialog editor multiple checkboxes box variable default
You cannot have multiple checkboxes in a Dialog Box with the same variable name.
If you have multiple checkboxes with the same variable name, the only box that can actually be checked by default is the '1' box. And on exit, the only boxes in the group that are counted are the highest-numbered box and any consecutive checked boxes "below" it numerically.
For example, if '1', '4', and '8' are checked, the return value is 12 (since the '2' box is unchecked, it and the '1' box are ignored); if '1', '2', and '4' are checked, the return value is 0 (since the '8' box is unchecked).
The solution is to use different variable names for each checkbox, each with a value of 1, and 'OR' them together to build a composite value.
For example:
box2 = 1 box4 = 1 ... Dialog("TEST") boxval = box1 | box2 | box3 | box4 ;NOTE: this is the Bitwise OR, not the Logical ORHere is some sample code:
MyDialogFormat=`WWWDLGED,5.0` MyDialogCaption=`WIL Dialog` MyDialogX=57 MyDialogY=78 MyDialogWidth=172 MyDialogHeight=202 MyDialogNumControls=7 MyDialog01=`60,52,49,DEFAULT,CHECKBOX,box1,"box1",1` MyDialog02=`60,68,49,DEFAULT,CHECKBOX,box2,"box2",1` MyDialog03=`60,84,49,DEFAULT,CHECKBOX,box3,"box3",1` MyDialog04=`60,100,49,DEFAULT,CHECKBOX,box4,"box4",1` MyDialog05=`25,132,49,DEFAULT,PUSHBUTTON,DEFAULT,"select all",2` MyDialog06=`86,132,49,DEFAULT,PUSHBUTTON,DEFAULT,"de-select all",3` MyDialog07=`51,161,51,DEFAULT,PUSHBUTTON,DEFAULT,"OK",1` :theDialog retval= Dialog("MyDialog") switch retval case 2 box1 = 1 box3 = 1 box2 = 1 box4 = 1 goto theDialog break case 3 box1 = 0 box2 = 0 box3 = 0 box4 = 0 goto theDialog break Endswitch
Article ID: W12851
Filename: Multiple Checkboxes.txt
File Created: 1999:04:15:16:50:04
Last Updated: 1999:04:15:16:50:04