Welcome to WSL!

Make yourself at home, but before posting, please may I ask you to read the following topics.


Posting 101
Server space, screenshots, and you

Thank you!

PS. please pretty please:


Image

Checking for a boolean value

User avatar
brysend
Posts: 31
Joined: Sat Nov 09, 2019 6:04 pm
Been thanked: 1 time

Checking for a boolean value

#1

Post by brysend » Wed May 20, 2020 11:41 pm

Hi WSL, hope yall staying safe.

I have edited a node's `edit controls` to add a checkbox.
I need to read this value in another node, setting opacity for a node.
I am aware of iif(statement), but not sure how to add the equality check for a checkbox control ?

I tried :
iif(myNode.checkbox == true)
iif(myNode.checkbox == 1)
iif(myNode.checkbox == yes)

but none worked. Any help ?
by SecondMan » Wed May 20, 2020 11:55 pm
Almost there :)

Code: Select all

iif(myNode.checkbox == 1, 1, 0)
iif works like this: iif ([condition],[return value if condition is true],[return value if condition is false])

Example:

Code: Select all

{
	Tools = ordered() {
		Background1 = Background {
			Inputs = {
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				MyCheckbox = Input { Value = 1, },
			},
			ViewInfo = OperatorInfo { Pos = { 275, 49.5 } },
			UserControls = ordered() {
				MyCheckbox = {
					LINKS_Name = "MyCheckbox",
					LINKID_DataType = "Number",
					INPID_InputControl = "CheckboxControl",
					INP_Integer = false,
					INP_MinScale = 0,
					INP_MaxScale = 1,
					INP_MinAllowed = -1000000,
					INP_MaxAllowed = 1000000,
					CBC_TriState = false,
					ICS_ControlPage = "Color"
				}
			}
		},
		BrightnessContrast1 = BrightnessContrast {
			CtrlWZoom = false,
			Inputs = {
				Lift = Input {
					Value = 1,
					Expression = "iif(Background1.MyCheckbox ==1,1,0)",
				},
				Input = Input {
					SourceOp = "Background1",
					Source = "Output",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 385, 49.5 } },
		}
	}
}
PS. this is not a development topic, but a scripting question, so moved it to the proper forum.
Go to full post

User avatar
SecondMan
Site Admin
Posts: 4456
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 27
Location: Vancouver, Canada
Been thanked: 109 times
Contact:

Re: Checking for a boolean value

#2

Post by SecondMan » Wed May 20, 2020 11:55 pm

Almost there :)

Code: Select all

iif(myNode.checkbox == 1, 1, 0)
iif works like this: iif ([condition],[return value if condition is true],[return value if condition is false])

Example:

Code: Select all

{
	Tools = ordered() {
		Background1 = Background {
			Inputs = {
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				MyCheckbox = Input { Value = 1, },
			},
			ViewInfo = OperatorInfo { Pos = { 275, 49.5 } },
			UserControls = ordered() {
				MyCheckbox = {
					LINKS_Name = "MyCheckbox",
					LINKID_DataType = "Number",
					INPID_InputControl = "CheckboxControl",
					INP_Integer = false,
					INP_MinScale = 0,
					INP_MaxScale = 1,
					INP_MinAllowed = -1000000,
					INP_MaxAllowed = 1000000,
					CBC_TriState = false,
					ICS_ControlPage = "Color"
				}
			}
		},
		BrightnessContrast1 = BrightnessContrast {
			CtrlWZoom = false,
			Inputs = {
				Lift = Input {
					Value = 1,
					Expression = "iif(Background1.MyCheckbox ==1,1,0)",
				},
				Input = Input {
					SourceOp = "Background1",
					Source = "Output",
				},
			},
			ViewInfo = OperatorInfo { Pos = { 385, 49.5 } },
		}
	}
}
PS. this is not a development topic, but a scripting question, so moved it to the proper forum.

User avatar
brysend
Posts: 31
Joined: Sat Nov 09, 2019 6:04 pm
Been thanked: 1 time

Re: Checking for a boolean value

#3

Post by brysend » Thu May 21, 2020 12:02 am

SecondMan wrote:
Wed May 20, 2020 11:55 pm
iif(myNode.checkbox == 1, 1, 0)
Thank you for the swift reply SecondMan, much appreciated!!