Define "current note" with action code

I think I missed something very basic… :frowning:

Is there a way to set the current note with action code? I would like to run:


or (depends)


on a range of notes without having to use an agent. Something like:

var:list allMyNotes     = collect(children(startNode),$IDString);

Maybe it’s just too early today - but this looks like such a basic task and I can’t find the answer…

Probably no help, but will the designator “this” do it.

  1. You do need to test that allMyNotes is empty, since .each(){ … } will do nothing if its list is empty. So now we have
var:list allMyNotes     = collect(children(startNode),$IDString);
  1. The unlink and link operators accept group designators, so you could avoid the explicit loop:
  1. For a rule, this is bound to the note that owns the rule. If you want some other note to be this, you use eval():
eval(/path/to/note,"unlinkFrom(all,'agree')" );

1 Like

There is currently no action code that selects a note, as in selected in the current view in the AI. But, there will be such a method in v9.6.0, which is not far off. :slight_smile:

Within action code (i.e no affecting the on screen selection) a path or IDString can be used to set the locus of action:

 // this sets $Color in the current UI selected note, i.e. default usage
$Color = "blue";
// sets $Color in note "Some Note"
$Color("Some Note") = "blue";
// sets $Color in note at path /path/to/Some Note
$Color(/path/to/Some Note) = "blue";
/// sets $Color in note with IDString 'tbx:BkrVq9'
$Color("tbx:BkrVq9") = "blue";

@webline, take a look at the stamp code used here, Replacing the Linktype of a link between notes with action code in a stamp?.

In your action code you could also use stamp(“this action”). This is a method I use to apply action code to a specific note. There are of course, other methods.

1 Like

I like this one :slight_smile:

1 Like

Didn’t test but this should be possible by using AppleScript via runCommand.

Oh - yes - that’s another nice idea - I stay with eval() - that’s working great.


Upps, didn’t see the eval solution.