cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
SG
SG
Level III

Disabling all or individual check boxes not able to be re-enabled with opposite method

I have two sets of check boxes and one is being used to control which options are enabled on the other. I seem to have run into an issue using Enable and Enable Item. If I have previously disabled all the checkboxes I am unable to enable them individually unless I enable them all first. Conversly, if I disable individual check boxes, it appears I am unable to enable them all at once.

 

As it is currently, if one machine is selected certain boxes disable. However, I am unable to get them to re-enable using Enable(1).

 

I have attached the code for my window below. I am hoping there is something I am missing and I don't need to use enable items for everything as that will get cumbersome as I continue and if new machines are added in the future.

 

New Window("XYZTEC Sensor Verification",
	<<Modal,
	Text Box("XYZTEC Sensor Verification", Set Font Style("Bold"), Set Font Size(16)),
	Text Box(" "),	// places blank line beneath title
	Text Box("Select Date Range:", Set Font Style("Bold Underline")),
	V List Box(
		H List Box(
			V List Box(
				Text Box("Start Date:"),
				sDate = Number Edit Box((Today() - 31536000), 9, << Set Format(Format("m/d/y"))),
				Text Box(" "),	// places blank line spacer
				Text Box("Select Machine(s):", Set Font Style("Bold Underline")),
				machine =  Check Box({"Both","M-1517","M-1774"}, << Set All(1))
			),
			V List Box(
				Text Box("          ")
			),
			V List Box(
				Text Box("End Date:"),
				eDate = Number Edit Box(Today(), 9, << Set Format(Format("m/d/y"))),
				Text Box(" "),	// places blank line spacer
				Text Box("Select Sensor(s):", Set Font Style("Bold Underline")),
				sensor = Check Box({"Pull 100 gf", "Pull 1kgf", "Pull 100kgf", "RotatingShear 100 gf", "RotatingShear 1kgf", "RotatingShear 10kgf", "Shear 100kgf"}, << Set All(1))
			)
		)
	),
	Text Box(" "),	// places blank line beneath check boxes
	H List Box (Button Box("OK", flag = 1), Button Box("Cancel", flag = 0)),
	
	// ---- formatting check boxes automatic enable/disable based on machine selection ----
	machine << setFunction(
		Function({this, button},
			If (button == 1, 
				(If (this << get(button), 
					(machine << Set All(1); sensor << Enable(1); sensor << Set All(1)),
					(machine << Set All(0); sensor << Enable(0); sensor << Set All(0)))
				),
				If (button == 2,
					(If (this << get(button),
						(machine << Set(1,0); sensor << Enable(1); sensor << Enable Item(3,0); sensor << Enable Item(4,0); sensor << Enable Item(5,0)),
						(machine << Set(1,0); sensor << Set All(0); sensor << Enable(1); sensor << Enable Item(2,0)))
					),
					If (button == 3,
						(If (this << get(button),
							(machine << Set(1,0); sensor << Enable(1); sensor << Enable Item(2,0)),
							(machine << Set(1,0); sensor << Set All(0); sensor << Enable(1); sensor << Enable Item(3,0); sensor << Enable Item(4,0); sensor << Enable Item(5,0)))
						),
						(sensor << Enable(0); sensor << Set All(0))
					)
				)
			)
		)
	)
);
1 REPLY 1
SG
SG
Level III

Re: Disabling all or individual check boxes not able to be re-enabled with opposite method

I have revised my enable/disable code to only use enable items and it works better now.

 

However, I still do not understand how I would set the sensor check boxes if multiple machine check boxes are selected. I have included by revised enable/disable code.

Is there an easier way to do this that I am unaware of?

 

	machine << setFunction(
		Function({this, button},
			If (button == 3,
				(If (this << get(button),
					(machine << Set(1,0); sensor << Enable Item(1,1); sensor << Enable Item(2,0); sensor << Enable Item(3,1); sensor << Enable Item(4,1); sensor << Enable Item(5,1); sensor << Enable Item(6,1); sensor << Enable Item(7,1))
				)),
				If (button == 2,
					(If (this << get(button),
						(machine << Set(1,0); sensor << Enable Item(1,1); sensor << Enable Item(2,1); sensor << Enable Item(3,0); sensor << Enable Item(4,0); sensor << Enable Item(5,0); sensor << Enable Item(6,1); sensor << Enable Item(7,1))
					)),
					If (button == 1,
						(If (this << get(button),
							(machine << Set All(1); sensor << Enable Item(1,1); sensor << Enable Item(2,1); sensor << Enable Item(3,1); sensor << Enable Item(4,1); sensor << Enable Item(5,1); sensor << Enable Item(6,1); sensor << Enable Item(7,1); sensor << Set All(1)),
							(machine << Set All(0); sensor << Enable Item(1,0); sensor << Enable Item(2,0); sensor << Enable Item(3,0); sensor << Enable Item(4,0); sensor << Enable Item(5,0); sensor << Enable Item(6,0); sensor << Enable Item(7,0); sensor << Set All(0))
						))
					)
				)
			)
		)
	)