Action code in Attribute Browser


(Rene Trappel) #1

Hi. There is (it seems) an option to enter action code in the Attribute Browser. Adding something there, however, does not seem to have any consequences. Is this a bug, a feature or am I misunderstanding this field?


(Mark Anderson) #2

The aim of the query/action is as a form of agent within AB view. If you can’t slim down your list of in-scope notes via container, the query allows you to apply a query within the selected container (default contain is the whole doc).

The action is essentially like an agent action and should act on any matching note - i.e. any note in the current AB view.

You proposed action may not work, once it does, in the way you suspect as each time that action runs, it will add the same string to the end of $SloganName again, and again, and again…etc. Unless you are filtering in the query for notes where $SloganName already ends with the desired suffix.

On the data given, I can’t say why the action isn’t working but I’d suggest trying with a small test file and using basic roman alphabet values. The latter will help beat out if the issue is some odd Unicode issue.


(Rene Trappel) #3

Thanks again for the quick reply!

That is what I assumed.

The query includes a filter for that.

$Prototype=="*dokument-fragment" & $Text.icontains("美丽村庄") & !$SloganName.icontains("美丽村庄")

Thanks, will try this.


(Mark Anderson) #4

OK, that query makes sense and answers my concern about repeat actions. As you know the exact substring you want to match and where it will occur, you could use String.endsWith() rather than String.icontains() as I suspect the former is less regex/processor intensive. IOW the query term

!$SloganName.icontains("美丽村庄")

becomes

!$SloganName.endsWith("美丽村庄")

I tried my own small test and the action doesn’t seem to be executed. Might be a glitched. I’ve never really used the AB action in real work before so I might be doing something wrong.


(Rene Trappel) #5

Thanks for the suggestion, I did not know about “endsWith”. Does it only work with string-variables?

In regard to the main question (action code not working in the AB) I might have to mail @eastgate.


(Mark Anderson) #6

Here is a list of available actions and associated data types. Note the .endsWith() operator works on strings but many other attribute types are essentially strings, e.g. List or Set.

I’ve already raised the possibility of there being a glitch with AB view actions but it might also be useful to contact support yourself if you already have a tst case TBX that properly exposes the issue (and which you could let support see).


(eastgate) #7

For various reasons – possibly not good reasons, but not absurd – the Attribute Browser action is only applied to new notes created in the attribute browser view.


(Paul Walters) #8

How does one create a new note in the attribute browser view? In attribute browser view, all the relevant commands in the Note and File menus are greyed out; and the one that isn’t greyed out (Explode) doesn’t work.


(Rene Trappel) #9

Changing this would be huge improvement for my workflow (I would need agents way less often) and it seems that almost nobody else cares. :wink:


(Paul Walters) #10

???

There has always been significant appreciation of the attribute browser, for the reason you mention and others.


(Rene Trappel) #11

Sorry for the confusion. What I wanted to refer to was that apparently nobody took issue with the lack of functioning of action code in the AB in recent times. :smirk:


(James Fallows) #12

Agree 100% with @PaulWalters .

Easy way to test the “no one cares about the attribute browser” hypothesis: read one of the many extensive threads on how to use it and why it matters. Eg the one starting here:

Also

And


(Rene Trappel) #13

I was only talking/thinking about this:

I know that many love the AB (your posts on the topic have been an inspiration for me). Again, sorry for not being clearer on this.


(David) #14

For what it is worth, when I first started using Tinderbox, I thought the Attribute Browser was pretty powerful. However, I had a guess that the Action should do something like an agent’s action, but it never worked as I expected. So I assumed I was misunderstanding something and that I might find out later when I needed to. In other words, you’ve asked the question I should have asked. And, like you, I’d find it helpful if it worked as you and I seem to have expected.


(James Fallows) #15

Ah, understand, thanks.

In the sense of your original comment, it actually is true that I, personally, “don’t care” about having this kind of query/action functionality within the Attribute Browser.

I use the query part of the AB very intensively – working it almost to death! The AB is my go-to working palette when I’m organizing notes for an article or book, when I’m trying to sort out the status of various to-do’s or projects, when I’m categorizing financial data, etc.

But toward those ends I use the queries strictly to regulate and refine the display of what I’m seeing in the different sections of the AB view.

When I want to do something with them, 99% of the time I use the Column feature, and either (a) have a check-box, to switch something from “Undone” to “Done” etc, or (b) add a new string or set value to one of those attributes.

I very frequently want to change note values via checkbox or column-value. But I, personally, don’t ever want or need to make those changes on the basis of a query/action operations. (If and when I want to make changes via an agent or query, I go back to an outline view.)

I understand that other people’s work habits differ. This is why I didn’t register what you were asking about – it’s a use case that never comes up for me.


(Rene Trappel) #16

Off-topic: I do the same but struggle with one aspect of this. I use Scrivener to write and would like to retain a link to the note in the text so that I later can verify the quote. In the past I used “Tinderbox > Copy Note URL” and handmade UUIDs for this purpose, without being really happy with either solution. What do you use for linking a note in TBX to Scrivener/your word processor?

Maybe some more info on my use case is helpful. I’m looking at a policy called 乡村振兴 or Rural Rejuvenation, which is part of Xi’s Rejuvenation of the Chinese Nation. I noticed that in the key documents of this policy the term beautiful (美丽) is a new addition and now want to track all variants of its use in the variable $SloganName (of the type ‘set’).

The Attribute Browser is great to find all of these cases. I could then add terms like 美丽乡村 individually to all notes that carry it (or use an agent to do that for me) - but it would be great if I could automate it right in the Attribute Browser.


(James Fallows) #17

Here’s another possible solution: via Stamp or QuickStamp, which (in my experience) work fine within the Attribute Browser, and give you the agent/action power you are looking for.

Main functional differences between them, to best of my knowledge: (a) Stamps can be saved, so if there is an action you’ll want to perform frequently, you can set up it as a go-to stored stamp. QuickStamps, by contrast, are ad hoc and not saved. (b) Stamps can have full action code, and can do pretty much anything an agent can do. (If they don’t, I haven’t myself encountered the limit yet.) QuickStamps, by contrast, change the value of an attribute, but don’t deploy the whole action-code vocabulary. More info here.

Both Stamps and Quickstamps can apply to a single item, or to a range of selected items. What I’d do, in your use case:

  • Select the item(s) you care about, while you’re working in Attribute Browser
  • Call up the Stamp/Quickstamp menu, and either do an ad hoc change via Quickstamp, or apply a saved Stamp.
  • I think that the saved stamp could say something like $Tags=$Tags+"美丽乡村" (or whatever attribute you’re wanting to change). Expects will correct me, but I believe a formulation of that sort would add an additional value to a set-type attribute.

好运 ! [For onlookers: Good luck]

Update Thanks for clarification by @mwra, below, that the AB does not allow multi-item selection. But it’s quick and easy to apply stamps to them one by one.


(Mark Anderson) #18

A further useful point about stamps. When applied, the stamp’s code once on the selected note(s) (AB view actually doesn’t allow multiple selections).

The point here is you have very tight control of what happens to which notes.

Bear in mind the AB view doesn’t always refresh as often as other views. Some changes update the view, e.g. changes to attribute values tested by a query. This might seem an annoyance but in big/mature document it is actually a boon as it’s not always helpful if the view is trying to re-draw just as you are trying to read it. That said you can force a manual refresh by clicking on the current view’s tab; in fact i believe this method works for most (all?) view types.


(Pat Maddox) #19

Are there any plans to allow multiple selections in AB? That limitation is a pain.


(Mark Anderson) #20

I’m not aware of plans. I’d assumed the status quo is in part dictated by the underlying design. Still, no harm in making a feature request with a use case.