DT3 close databases via script

I’m trying to open/close database selectively by scripting. My idea is close some not frequently used databases with one script and then be able to open them when needed.

The script to open the dabases is working as expected:

tell application id "DNtp"
	open database "~/Databases/blah1.dtBase2"
	open database "~/Databases/blah2.dtBase2"
end tell

However the script to close them does nothing:

tell application id "DNtp"
	close "~/Databases/blah1.dtBase2"
	close "~/Databases/blah2.dtBase2"
end tell

Doesn’t matter what I try to “close” (file name with path, without path, database name…), the script runs and DT3 does nothing. What I’m doing wrong? Thanks.

Oh, found it:

tell application id "DNtp"
	set theDatabase to database "blah1"
    close theDatabase
    ...etc
end tell

An this is the ultimate script: if it is open, close it, and if it closed, open it:

tell application id "DNtp"
  try
     set theDatabase to database "Correo"
  close theDatabase
  on error
     open database "~/Databases/Correo.dtBase2"
  end try
end tell
1 Like

close “~/Databases/blah2.dtBase2”

This would not work as close doesn’t work with a file path.

1 Like