Tinderbox Forum

UnlinkToOriginal / UnlinkFromOriginal Usage

I’m having some trouble with UnlinkToOriginal and UnlinkFromOriginal in an agent action. No matter what I try I can’t seem to unlink notes using these functions.

Here is my situation. I’ve created two notes—Note1 and Note2—and created a single link from Note1 to Note2 called “concept”. I’ve also created an agent that queries $Name=="Note1" with the action unlinkToOriginal("Note2","concept"). The agent finds the note, but does not remove the link. I’ve tried something similar with UnlinkFromOriginal to no avail.

I’m stumped. Any help would be much appreciated!

I’m stumped, I can replicate this. Aha… it looks like a glitch of some sort. @eastgate?

I can get an agent action to use unlinkTo() to remove a link dragged from the Note1 alias to Note2, so it looks like an issue with the unlinkToOriginal() action.

I note that the action code boxes in the inspector don’t offer to auto-complete for either unlinkToOriginal() or unlinkFromOriginal(), so perhaps both are affected.

I think this is going to need a small demo file emailed here – there are lots of edge cases.

Here’s my test-bed model: link-error.tbx (105.9 KB)

Note1 links to Note2 as in the original case. I’ve also linked the Note1 alias in the agent to note 3. The agent is turned off. Before enabling it, note the agent action. after turning on, the unlink command unlinks the alias from Note3, but Note1 incorrectly remains linked.

I’ve discovered an additional error - or change from the past (documented) function of the (un)linkTo/From family of codes. Originally, the link type argument was optional: when creating links no second argument resulted in an un-typed link, and when unlinked an absence resulted in all links of the desired direction being deleted. It now appears unlink fails with no second parameter and a value of ".*" is needed in order to unlink regardless of link type. Notwithstanding, the above test with an agent action doesn’t work even with an explicit link type being given.

The demo file that Mark supplied replicates the problem I’m having. I have figured out a workaround, but it’s not pretty. I’ve moved the code into a stamp, and I apply that stamp to the original item in the agent action. That way I can just call UnlinkTo instead of UnlinkToOriginal. But, please let me know once you get a chance to take a look at Mark’s demo! I’m curious to know if this is a bug or if I’m calling the function incorrectly. Thanks!

I’ve got this fixed, and I’ll try to get a backstage build later today

2 Likes