Setting TimelineBand in an Edict or OnAdd


(Jordan Johnson) #1

I have a container serving as a timeline for my classes. I have several prototypes that correspond roughly to the bands of the timeline, and I’d like notes to be assigned to the right timeline band automatically.

This is the action code I’ve tried. I currently have it in the container’s $Edict (and I assume the principle would be the same if I used $OnAdd instead):

if ("Activity;Assessment;Resource;Problem".includes($Prototype)) {
  $TimelineBand = 2;
} else {
  if ("Learning goal;Standard".includes($Prototype)) {
    $TimelineBand = 1;
  }
}

However, it doesn’t seem to be taking effect. I’ve tried restarting Tinderbox (since I’ve read that Edicts run upon opening the document), and edicts are enabled on the container note.

Do I have something wrong with the action code, or is there something else I’m missing?


(Galen Menzel) #2

$OnAdd actions apply to a container’s children. $Edict actions apply to the container itself. So this action would only change the $TimelineBand of the container, not any of its children.


(Jordan Johnson) #3

OK, that explains the behavior clearly — so, on second thought, I think what I really needed to do is set $TimelineBand in the relevant prototypes.

Thanks.


(Galen Menzel) #4

Yes, looking at what you’re trying to do in this action code, that does seem like a better approach.


(Andreas Grimm) #5

That’s interesting since setting the $TimelineBand=1 in the Prototype does not set the TimelineBand to 1 in the note the Prototype is applied to.


(Jordan Johnson) #6

Yes; after writing that last post, I discovered this doesn’t seem to work consistently for me; AFAICT, creating a new note and setting $Prototype does set $TimelineBand, but if (for example) I change $Prototype again, $TimelineBand does not change accordingly.

Suggestions for a better solution?


(Galen Menzel) #7

Huh, I guess $TimelineBand is an intrinsic attribute.

In that case, @jxxmxxj, setting it in the prototype won’t work, since intrinsic attributes (such as $Width, $Container, and $TimelineBand, evidently) are not inherited from prototypes. Easiest would probably be to set it with an Edict in the prototype. I.e., add this Edict to the “Learning goal” and “Standard” prototypes:

$TimelineBand=1

And $TimelineBand=2 to the Edicts of the “Activity”, “Assessment”, “Resource”, and “Problem” prototypes.

Or you could use an agent, but if you do use an agent, make sure that you specify that you wish to set the timeline band in the original note, like this:

$TimelineBand(original) = 1

otherwise you will only set the timeline band of the alias (since aliases do not share intrinsic attributes with their original notes).


(Andreas Grimm) #8

In the respective Prototype create a Rule to set the $TimelineBand to either $TimelineBand=1 or $TimelineBand=2.

It should work.


(Galen Menzel) #9

For something like this that will change very rarely, I would use an edict rather than a rule. Rules update very frequently, and are wasteful unless you need those frequent updates.


(Paul Walters) #10

It is.

But I wonder why. Is there a case for showing prototypes on a timeline?