1. Combined conditions 2. Rule pane

I downloaded ‘Check it out.tbx’, I found on the forum and modified the code of the rule.

In my modified note, there are three attributes. The Xlastcheck is a string.

The Rule I have is:

if($Check_A & $Check_B) {

    $Check_B=false;
    $Xlastcheck="Check_C";

}

With this code, I was expecting that when Check_A and Check_B are checked, the Check_B would be unchecked and "Check_C’ would appear for $Xlastcheck. However, when I test, the results were unpredictable

Scenario 1

Interestingly, when I check both ‘Check_A’ and ‘Check_B’, there is no change in the value of $Xlastcheck.

However, when I uncheck B, the value of $Xlastcheck changes to ‘Check C’.

There is unpredictable behaviour of checking Check_A and Check_B

Scenario 2

If I check Check_A followed by Check_B and then uncheck Check_A, Check_B becomes unchecked as well.

Check it out b.zip (19.6 KB)

I wrote a long code in the rule pane (wrote it in BBedit and pasted it into the Rule pane). Howvever, I could not to the bottom half of my code. I did not see a vertical scroll to the rule pane. Is there a limited to the length of code in the Rule pane.

Thank you!

Scenario 1
Rules are reluctant to run on notes that are selected, since the Rule might undo something you’re working on. If you deselect and reselect the note, I believe the results will be as you expect.

Scenario 2
If you check both checkboxes and the rule runs, the rule will uncheck Check_B but might not immediately update the Displayed Attributes Table. This leads to the potential result you observed.

Long Code
The code editor in the Rule Inspector does not scroll, though the window can expand to accommodate longer passages. Short rules are best! When a rule starts to get long, consider using functions to make it easier to follow.

@eastgate Thank you! Yes, when I deselect and reselect the note, the code is worked fine!

I searched the web for a video tutorial on functions but, could not find. If there is, appreciate if you could direct me to it.

Thank you!

If working on a rule or edict in the Inspector, consider unticking the ‘enabled’ box. This stops the app trying to run this notes rile (or edict) while you work on the code and until you tick the box again.

@mwra thank you for the tip regarding ‘enabled’ box!

1 Like

I’m not sure there’s a video tutorial. There’s a good meetup from a while back on using functions, and of course there’s the page in Tinderbox Help for starters, and in aTbRef for more depth.

@eastgate thank you. I will follow-up those leads!