Setting $Container of a note with '/' in the $Name doesn't work

(Pat Maddox) #1

I want a stamp that moves notes from /Notes/INBOX to /Notes/Archive.

I have this stamp:

var inbox("/Notes/INBOX");
var archive("/Notes/Archive");
var notes;
notes = collect(children(inbox), $Path);
notes.each(note) {
  $Container(note) = archive;

It works for most notes, but it doesn’t work for notes with a ‘/’ in the $Name.

I tried a solution using find():

var inbox("/Notes/INBOX");
var archive("/Notes/Archive");
var notes;
noteIDs = collect(children(inbox), $ID);
noteIDs.each(noteID) {
    var note;
    note = find($ID == noteID);
    $Container(note) = archive;

It doesn’t work.

How can I write a stamp that works for all notes regardless of $Name?

Example: inbox-cleanup.tbx (56.6 KB)

(Galen Menzel) #2

From what I can tell it seems like Tinderbox uses slashes as container separators, so this might just be a case of “don’t do that,” just like you can’t have slashes in Unix filenames. I’d be interested to hear from @eastgate if there is a work around.

This stamp fails because you haven’t declared the noteIDs variable. If you declare noteIDs, this stamp acts just like the first stamp.

(Pat Maddox) #3

:open_mouth: whoops…


(post must be at least 20 characters)

(Mark Anderson) #4

This is my understanding. Slashes (and parentheses) seem to be non-escapable and thus whilst valid in names for ordinary use they cause a silent failure in most action code. in my research work, where notes are often the names of papers which include such titles, I normally save the ‘real’ name as a user attribute and use that as Display expression whilst I bowdlerise the actual note $Name to work around this limitation. It’s a practical workaround if bit of a faff to do.