Naive question(s)

I’m presently trying to make a script for DTPro which does the following:
1- I select one or several items in my database
2-For each item “thisitem” in selection, the script will check if there exists in the group “comments” of mydatabase, a text file named “thisitem”& “-comments(n)”
3-If “thisitem”& “-comments(n)” exists, then the file "“thisitem”& “-comments(n+1)” is created, else the file “thisitem”& “-comments(n)” is created

My questions
For step 2:
I have tried something like “if exists record child searchedrecord of parent “comments” then etc…”. This does not work.
(It is possible to check the existence of the record by using try- do something with searchedrecord -end try, but I’d like to know if thre’s a better way to do that.)

For step 3:
I did not find how to make the script create a rich text file (type: text works, but type: rich text does not create anything)




assuming that I really understand your intention, this script should (more or less) do what you want:

tell application "DEVONthink Pro"
	set theSel to the selection
	set theLocation to "comments/"
	set theGroup to create location theLocation
	repeat with theItem in theSel
		if type of theItem is not group then
				set theName to name of theItem
				set n to 1
					set theCommentsName to theName & "-comments(" & (n as string) & ")"
					if not (exists record at (theLocation & theCommentsName)) then exit repeat
					set n to n + 1
				end repeat
				create record with {name:theCommentsName, type:rtf, rich text:""} in theGroup
			end try
		end if
	end repeat
end tell

Thanks, Christian,

‘:D’ That’s exactly what I was trying to do!!! ‘:D’


I’ve another question:

If i write:
open window for record child “thisrecord” of parent “thisparent” of database 1,
the expected window is opened, but

I’d like to open, move, etc… a record located a the first level of my database,
I try:open window for record “thisrecord” of database 1, and get an error message.

I could not find how to manipulate records located at the top level of DT database.


You could use one of the following two lines:

	set theRecord to record named "name" of database 1
	set theRecord to child named "name" of root of database 1

Thanks again


1-I’m discovering Devon Agent, and I’ m trying to make a stay open script which records the browsing history in DTPro. This script checks, say, every 2 seconds, the url of the front window of DA, and drops it to DTPro.
I don’t like the idea of checking DA every 2 seconds; I would prefer that the script be activated only when DA loads a new page. Is this somehow possible?

2-This question is more or less related to 1:
For getting documents from, I have a script which opens each of the links leading to an abstract, and then records the source, drops it to DTPro, etc…
Before getting the source of the front DA window, I have to check that the page is completly loaded. So, I use this kind of loop:

open URL this_url
repeat with i from 1 to 100
set thesource to the source of window 1
if thesource contains “” then exit repeat
delay 0.1
end repeat

Is there a better way of doing it (or better, is there a possibility to get the information , I mean the source of the html page whose internet location is this_url, without displaying it in DA?)

Thanks a lot,



No, that’s not possible.

Two solutions:

  1. A simple loop waiting for the page:

		repeat while loading of browser 1
		end repeat

  1. Downloading HTML without using a window:

set theHTML to download markup from this_url

Thanks Christian, for these informations.