IF


IF[0] - IF[9]

Executes specified commands if the set conditions are met.
Operates autonomously, set up once, preferably in the boot.txt file.

IF[0]CT:LED(ON);STD@TRUE
If the condition is met, the LED lights up, and a message is sent to STDOUT (TRUE).
IF[0]CF:LED(OFF);STD@FALSE
If the condition changes from true to false, the LED turns off, and a message is sent to STDOUT (FALSE).

IF[]IR=1000
Checks conditions IF[0]-IF[9] every second. Milliseconds. Min:5 Default:50

NUM[0]=0
NUM[0]=5
NUM[0]=10
IF[0](NUM[0]=5)
If NUM[0] equals 5, the LED lights up.
IF[0](NUM[0]!=5)
If NUM[0] does not equal 5, the LED lights up.
IF[0](NUM[0]>0)
If NUM[0] is greater than zero, the LED lights up.
IF[0](NUM[0]>=0)
If NUM[0] is greater than or equal to zero, the LED lights up.
IF[0](NUM[0]<10)
If NUM[0] is less than 10, the LED lights up.
IF[0](NUM[0]<=10)
If NUM[0] is less than or equal to 10, the LED lights up.
IF[0](NUM[0]=NUM[1])
If NUM[0] equals NUM[1], the LED lights up.

STR[1]=ON
STR[1]=OFF
STR[1]!
STR[2]=ON
STR[2]=OFF
IF[0](STR[1]=ON)
If STR[1] is "ON", the LED lights up.
IF[0](STR[1]!=ON)
If STR[1] is not "ON", the LED lights up.
IF[0](STR[1])
If STR[1] is not empty, the LED lights up.
IF[0](!STR[1])
If STR[1] is empty, the LED lights up.
IF[0](STR[1]=STR[2])
If STR[1] equals STR[2], the LED lights up.

GPIO[D1]L
GPIO[D1]H
IF[0](GPIO[D1]H)
If GPIO[D1] is high, the LED lights up. Data direction doesn't matter.
IF[0](GPIO[D1]L)
If GPIO[D1] is low, the LED lights up. Data direction doesn't matter.

TIMER[1](2s,4s,3x)
TIMER[1]E
IF[0](TIMER[1]0)
If TIMER[0] is inactive, the LED lights up.
IF[0](TIMER[1]1)
If TIMER[0]'s time1 is ticking, the LED lights up.
IF[0](TIMER[1]2)
If TIMER[0]'s time2 is ticking, the LED lights up.

STR[0]=%TIME.txt|
STR[1]#STR[0]

IF[0](#data.txt)
If the data.txt file exists, the led lights up.
IF[0](!#STR[0])
If file STR[0] does not exist, the led is lit.

IF[1](GPIO[D1]H)
IF[0](IF[1])
If IF[1] is true, the LED lights up.
IF[0](!IF[1])
If IF[1] is false, the LED lights up.

IF[0](NUM[0]>2)AND(NUM[0]<8)
If NUM[0] is between 3 and 7, inclusive, the LED lights up.
IF[0](NUM[0]>0)OR(STR[1]=ON)
If NUM[0] is greater than zero OR STR[1] is "ON", the LED lights up.

IF[0]@
Sends the state of IF[0] to STDOUT.

IF[0]RS
Clears settings (CF, CT).

IF

When a command is issued, it checks the conditions; if true, it executes the commands.
Useful in boot.txt or when some event occurs.

IF(NUM[0]>0)AND(GPIO[D1]H):LED(FLASH)
If NUM[0] is greater than zero AND GPIO[D1] is high, the LED flashes.
Conditions are identical to IF[0] conditions.

IF(NUM[0]>0):LED(ON) ! LED(OFF)
If NUM[0] is greater than zero, the LED lights up; otherwise, it turns off.



Examples

Code-operated door opener.
GPIO[D1]L|
TIMER[0]CS:GPIO[D1]H|
TIMER[0]CF:GPIO[D1]L|
IF[0]CT:STR[0]!;TIMER[0](5s)|
IF[0]CF:STR[0]!|
IF[0](STR[0]=1234)

<html> <body> <H1>CODE</H1><br> <input type="number" id="code" onkeyup="check();"> <br><br> <script type="text/javascript" src="tools.js"></script> <script> startWS(0); function onOpen() { sendWS('STR[0]!'); } function check() { var incode = document.getElementById("code").value; if (incode.length >= 4) { sendWS('STR[0]=' + incode); document.getElementById("code").value = ""; } } </script> </body> </html>