What would cause that URL field cannot be copied into?


(Malcolm) #1

I’m stumped. I’m importing from DevonThink (DT) a file of annotations for a scientific publication on sea ice. This is something I plan to do on a grand scale in the future e.g. many files to help design a new satellite mission.

I use the “Explode” function together with dedicated prototype to split the file into chunks (one note for each quote from the paper with the $Name of the note set to my annotation for that quote) and store the results. In general it works well (see truncated screenshot below).

You will see that there is an URL key attribute called DTURL which I use to store the link to the DevonThink. For the example above it works - however the next quotation does not work. I cannot copy a well-formed URL into the DTURL field even if I do it by hand. I’m wondering whether I’ve missed something or it’s a bug in the software. Under what circumstances can one NOT copy a URL into a URL field ?

I upload the example document as a reference. URLProblem.tbx (209.0 KB)


(eastgate) #2

Your notes have a Rule that sets $DTURL based on the text of the note. So, though you manually change the value of $DTURL, the rule come along and changes it back.

Most likely, you wanted this to be an OnAdd action rather than a rule.

Or, if you want to set the value initially from the text but also want to allow manual overrides, use |= in your rule to assign a value only if there isn’t already a value.


(Mark Anderson) #3

You don’t say how you did the explode but using \n\n I got 2 notes of preamble and 21 per-quotation notes.

I found 2 notes had no URL and I traced this to known limitations of .split(). The third quotation note generates no $MyList data because the abstract text has an unclosed parenthesis (try adding a closing ) and you’ll find the code works. Quotation 18 fails as the text contains a semi-colon. Change that to some other character and the code works.


(Malcolm) #4

Thanks for the valuable feedback. Correct I used \n\n+ a prototype for the Explode command.

I’ve tried reverse engineering from both answers above. It looks like a combination problem:

  • the limitations of split() where the result depends on the characters in the text e.g. unclosed bracket
  • the Rule overwriting my manual input into the DTURL field

I’m finding Stamps an very useful tool for trying out new code on notes and have come up with a more robust way of extracting the information I wanted.

$MyAnnotation=; $DTURL=;
$MyString=$Text; $MyString=$Text.replace("\n","");
if($MyString.contains(“Page.+(\d+):(.+)Link:(.+)Annotation:(.+)”)){$MyNumber=$1;$MyQuote=$2;$DTURL=$3;$MyAnnotation=$4}; $MyString=$DTURL.substr(1,$DTURL.size-2)+$MyNumber; $DTURL=$MyString;$Name=$MyAnnotation;

At the heart of the code is the if statement with RegEx matching. It works. I manually delete the two extra notes at the beginning and the final note which are not quotations, something I can live with.

My final question is one of form. For Explode is a rule within the prototype is the best way to proceed ? All I want is a single action at the moment the notes are created to copy the information properly, not a rule that runs continuously for the lifetime of the note. I don’t think the $OnAdd action is activated during an Explode command so what are the alternatives ? Copy the rule into the Explode action itself (which I cannot save) ?

See the screenshot of my Explode command below.

image


(eastgate) #5

The prototype rule, which will be inherited by each exploded note, will be applied continuously to each imported note. So, that’s not what you want.

The Explode action, which you are currently using to set the prototype, does what you want. It is performed once, after the new note is created.

If you have a complex explode action that you want to use often, make a stamp named ExplodeAction. Then, save copying and pasting by simply invoking the stamp as an action

Action : ExplodeAction; $Prototype="elegant:

The Explode Action will be persistent through the current session. It becomes the OnAdd action of the Exploded Notes container.


(Malcolm) #6

Very clear now. As I have maybe 40-70 annotation files in DT to import over a period of weeks and many TB sessions a stamp will do nicely both as a code repository and as an action during the Explode. The use of both a stamp and prototype for the Explode is elegant as the stamp is used to copy and populate the note attributes and the prototype to define the look of the note.

Many thanks thanks to you and Mark for your help. Hopefully also interesting for the wider TB community.