Hello @mwra,
Your idea with the dictionary was great. I have to admit, I didn’t understand it at first because I didn’t know what the dictionary data type was.
But I was able to implement your suggestion into concrete code. I have further developed the idea to quickly capture and use the data.
In summary:
The semantic meaning of a link between two notes is often limited to a specific period. Currently, Tinderbox does not allow capturing this period as such. The goal is to be able to do this from the moment the link is created, not several work steps later.
Later, in the Timeline View, these links can be displayed, showing which links overlap and which do not (e.g., you find three people who worked at company X, and on the timeline, you can see who worked there for how long and where the periods overlap).
Solution Proposal:
When creating a link, via the link pop-up, you have the option to fill in the fields Target, Title, and Class. If these fields (or one of them) are not needed, they can be repurposed for storing time periods.
For example, use the Target field for the start date and the Title field for the end date. Then, an Action Code reads these fields and stores them as values in an attribute, e.g., $MyDictionary.
The code for this looks like:
var:dict tempDict = dictionary(); // Empty dictionary for the results
eachLink(this){
if(this["type"] == "employed"){ // Check if the link is of type "employed"
var:string key = this["destination"]; // Destination note as key
var:string target = this["target"]; // "Target" as value 1
var:string title = this["title"]; // "Title" as value 2
tempDict[key] = target + " | " + title; // Add key-value pair (combined value)
}
}
$MyDictionary = tempDict; // Store results in the attribute (e.g., $MyDictionary)
That works great.
But in the next step, specific values (namely those belonging to a certain key) should be read from $MyDictionary and stored in $StartDate and $EndDate, so a timeline can be displayed in the Timeline View.
At this point, I can’t proceed. My code for reading values from $MyDictionary does not work, and I don’t know why.
Here’s how the code looks:
if($MyDictionary.containsKey("Byte Me")) {
var:string value = $MyDictionary["Byte Me"]; // Get the value for the key "Byte Me"
var:list values = value.split("|"); // Split the dates (values) into two parts, which are separated by "|"
if(values.count >= 2) {
$StartDate = date(values.at(0).replace(" ", "").replace(".", "/")); // Convert the first value into a date
$EndDate = date(values.at(1).replace(" ", "").replace(".", "/")); // Convert the second value into a date
}
}
Do you have any idea why this part of the code isn’t working?
File:
distantly_related_02.tbx (494.4 KB)
Best regards