Hi all, sorry if this is not the correct forum category for this.
I grabbed one of Christian 2004 scripts, replicated it below.
It works great when there is selected text in the record, but if I want to add a line to make sure some text is selected, I get the error “The variable this_selection is not defined.”
What am I doing wrong?
tx for helping!
-- Script Format > Body Normal
-- Created by Christian Grunenberg on Sat May 15 2004.
-- Copyright (c) 2004-2005. All rights reserved.
tell application id "DNtp"
set this_selection to ""
try
set this_selection to the selected text of think window 1
if this_selection is "" then error "Please select some text."
tell selected text of think window 1
set properties to {alignment:justified, font:"Open Sans", size:14, color:{5000, 5000, 5000}, background:{65535, 65535, 65535}}
end tell
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
end try
end tell
It is the script I’m using
By document, you mean the record in DT - it is an .rtf
What confuses me:
If I don’t include the lines
set this_selection to “”
if this_selection is “” then error “Please select some text.”
and just tell DNtp to set the properties of the selected text, then all works fine (of course, because of the “try” if there’s no selected text it just fails silently)
The latest version of the script that ships with DEVONthink is actually this one:
-- Script Format > Body Normal
-- Created by Christian Grunenberg on Sat May 15 2004.
-- Copyright (c) 2004-2014. All rights reserved.
tell application id "DNtp"
try
tell selected text of think window 1
set properties to {alignment:justified, font:"Times", size:12, color:{5000, 5000, 5000}, background:{65535, 65535, 65535}}
end tell
end try
end tell
Christian, I believe I understand why I am making a logical error already in the 2 lines I posted - if there’s no selection, then the var this_selection was not defined, correct? Even if I previously set it to “”.
So how do I write AS to tell me no text has been selected in the record?
not knowing you all. but this is how I picture the company is/runs…
You are from Germany Originally and a decade or so ago you moved to the US to over see the HQ on behalf of Eric Böhnisch-Volkmann and Cristian is the “lead” person in Germany. Although Eric and Cristian still live in Germany, they sort of call out the moves all the way from there yet the HQ is in the US. is it safe to say Eric is the big guy and Cristian is the right hand and you are the left lol and also there is a “junior” person behind the scene, the dude that is in charge of fixing little bugs here and there, what’s his name? dude that fixed the Sorter dock tab
Also picturing you joined the company in early 2000s just like Cristian.
All of this, I might be way off on my assumptions lol
Hmm… nice picture but not really close to reality I live in the Czech Republic now and founded the company together with Eric, Jim joined as later but he’s not German despite his name
There is no junior person in the company. Our other developer is Alan, who is very talented and capable, working on parts of both DEVONthink and DEVONthink To Go.
PS: I am US born and raised, though my heritage is (mostly) German. My great grandparents came to the States from Northern Germany.