Tinderbox Forum

Getting checkbox to be checked if all children are checked


(Ralph Alvy) #1

Here’s what I have in the Action of a parent checkbox:

$Checked=all(children,$Checked);

But I find that will cause the parent checkbox to be checked at all times. What am I doing wrong here? I want the parent to be check if and only if all its children are checked.


(Ralph Alvy) #2

Correction. That code is in Rule, not Action.


(Mark Anderson) #3

I’m not sure about an all() operator, where is it described? From the description, I think you want the every() operator - see here.

every() is true if every, i.e. all, in-scope items are true

any() is true if any in-scope items are true


(Ralph Alvy) #5

Yes. I see I needed the every operator. But I also found that I needed to add a condition that there are some children, otherwise the checkbox gets checked:

$Checked=every(children,$Checked)&$ChildCount>0;


(eastgate) #6

That’s right.

every(designator, value)

is false if value is false for any designated note. If there are no designated notes at all, every() is therefore true.


(Mark Anderson) #7

I’ve updated my note on every() to reflect this edge case (@eastgate’s post above), where the group is empty, as I suspect that for non-programmers the logic is only obvious in hindsight (if then!). I’ve tested a bit and it seems the edge case doesn’t apply (correct?) to the any() operator.

In updating the note, a hat tip to @ralvy, whose example using a second qualifier I have borrowed. I transposed the two expressions in my article to make the use of the qualifier more obvious.


(Ralph Alvy) #8

Is there a page where I can see all possible code strings in alphabetical order? I find it difficult to find this or that piece of code in the TB reference page. Or a search bar that will burrow down through all available pages in that reference site?


(Paul Walters) #9

Use the Quick Links on the top of the page for alpha lists of Action Codes, Export Codes etc. For more detail open and search the Site Map.

There are different classifications of “code” so a global alpha list might be more confusing than helping.


(Ralph Alvy) #10

Well, I find it difficult to sometimes figure out what Category I should drill down on. For instance, I still can’t find the code for determining if an item Contains a particular String.


(Mark Anderson) #11

_[Disclaimer: I am the sole author of aTbRef - it’s a public resource but my private initiative. Input corrections always welcome, though.]

Yes! Scroll to the bottom of every page in aTbRef. Glitches in the current Google indexing implementation means that stopped working (no explanation from Google as to a fix) which is why a DuckDuckGo alternative is offered.

All code strings? That’s really a near impossible task given that Tinderbox is a toolbox and there are many, many different ways to fashion expressions and queries. However, aTbRef contains exhaustive and IFAIK complete listings of current (but excluding deprecated):

  • system attributes
  • action codes
  • export codes
  • action code designators
  • data format strings
  • and more

Moreover most of those listings are in turn re-listed in several ways, e.g. attributes by data type, by purpose, etc. Indeed, the lists are also cross-referenced ("other things of this type/class/group). I’m not sure how much finer to grind things. The easiest way to find the big listings are by using the links at the top/bottom margins of any page on the site.

I would also note at aTbRef is a reference as to what features exist and their general design intent. It is not a “How to do X” resource. That’s a much bigger issue and best answered by a question here. Look at Help, aTbRef etc., and if you can’t figure the answer or get unexpected results, ask here, bearing in mind we are fellow users and only a few of whom are from a programming background. If you’re about to pen a post starting “Obviously,…” or “Everybody…”, welcome to the knowledge that individual use of Tinderbox has proven (over the 14 years I’ve been helping) to be quite idiosyncratic so the right code for each of us may not be of immediate use to others except to learn from.

If there’s a reference fact you can’t find in aTbRef I’m happy to hear about it as I hope can be attested to by some of the regular contributors here of aTbRef errors and omissions. I write it for the general Tinderbox community so I’m eager to avoid errors and un-described features; the last edit was only just this morning.


(Paul Walters) #12

I understand. That sort of query is why I always start with the site map and do a Find command with Safari (⌘F) to look for “contain” then cycle through the results with the tab key until I see a topic name that likely is a good hit. This works faster for me then the built in search box.


(Ralph Alvy) #13

That does it. Thanks, Mark. And thanks for your work here.


(Ralph Alvy) #14

Perfect. Thanks for this Paul.


(Ralph Alvy) #15

Mark,

Sorry for my short reply after such a detailed on you gave me. I had to run back to patients and only had a minute or so to reply to you. That said, now that I know about that bottom-of-the-page search field, I now use either that or the TbRef Site Map as recommended by Paul.