logo elektroda
logo elektroda
X
logo elektroda

OpenBeken CH22 Less Than CH23 Syntax for SetChannel 12 0

User question

syntax if $CH22 <$CH23 then SetChannel 12 0

Artificial Intelligence ResponseLABEL_AI_GENERATED

Direct answer to the question

For OpenBeken scripting, write it like this:

if $CH22<$CH23 then "SetChannel 12 0"

The important part is that the command after then should be quoted because it contains spaces:

"SetChannel 12 0"

So your intended logic is:

If channel 22 is less than channel 23, set channel 12 to 0.


Detailed problem analysis

Your original line was essentially:

if $CH22 <$CH23 then SetChannel 12 0

or, with HTML escaping:

if $CH22 &lt;$CH23 then SetChannel 12 0

In actual OpenBeken script syntax, &lt; must be written as the real less-than character:

<

So the comparison should be:

$CH22<$CH23

The corrected full command is:

if $CH22<$CH23 then "SetChannel 12 0"

The quotes are needed because SetChannel 12 0 is one command with arguments. Without quotes, the script parser may treat SetChannel, 12, and 0 as separate tokens belonging to the if statement rather than as the command to execute.


Recommended robust version

If you will use this logic more than once, define an alias:

alias CheckCH if $CH22<$CH23 then "SetChannel 12 0"

Then call it with:

CheckCH

If you want it to run repeatedly, for example every second:

alias CheckCH if $CH22<$CH23 then "SetChannel 12 0"
addRepeatingEvent 1 -1 CheckCH

Or, if you want it to run when either channel changes:

alias CheckCH if $CH22<$CH23 then "SetChannel 12 0"
addChangeHandler Channel22 CheckCH
addChangeHandler Channel23 CheckCH

Practical guidelines

Use this if the condition should be checked only once, for example at boot:

if $CH22<$CH23 then "SetChannel 12 0"

Use this if it should be checked continuously:

alias CheckCH if $CH22<$CH23 then "SetChannel 12 0"
addRepeatingEvent 1 -1 CheckCH

Use this if it should react only when channel 22 or 23 changes:

alias CheckCH if $CH22<$CH23 then "SetChannel 12 0"
addChangeHandler Channel22 CheckCH
addChangeHandler Channel23 CheckCH

Brief summary

Correct syntax:

if $CH22<$CH23 then "SetChannel 12 0"

Do not use &lt; in the actual script. Use the real < symbol. Quote the command after then because SetChannel 12 0 contains spaces.

Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.

Ask additional question

Wait...(2min)