On Jul 28, 2009, at 1:54 AM, Andreas Fischlin wrote:

Dear Christiaan,

Thanks for your attempt to help, greatly appreciated.
First problem: You can't write 'file aPath' in a script. The "file" type in AppleScript is very buggy. It generally should be considered read-only. When you want to create a file object you should use either "POSIX file" or "file specification", I always use the former. This is not a BibDesk bug, it's an AppleScript bug (it does not work in any app).
Ok, indeed, AppleScript is terrible in this respect. But what type of file specification does the export command want?

A file object, or anything that can be coerced to one.

But you just can't get a file object by typing a file object specifier, because Apple forgot to implement a handler for those.

And save is happy with what I tried to do, so the generality of your statement is not always given either.

That seems to be something recent, I guess the (built-in) handler for the save command has some workarounds for it. However a workaround doesn't mean the bug doesn't exist, which you can check by simply executing a script with just a file object specifier /without/ any script command. Anyway it does not matter, this is really an exception to the rule. Apparently AppleScript is as inconsistent in when it fails as it is in when its works.

BTW, I tried all forms, as file reference,

... that should be "file specification", not "file reference"

as alias,

... an alias requires the file to exist

as POSIX file,

... a POSIX file needs a POSIX style path, not a Mac style path. And it works.

but none of these seems to work. But whatever, all is fine with me as long as I would know what to do, i.e. what does export want? A file reference of an open file? An alias to an open file? Then I would need to create it first or a POSIX file to a not yet existing file, which export then will open itself? Would you perhaps know?


A reference to an open file makes no sense, because you're saving, not reading. So you can't use an alias, and must use a file specification or POSIX file.


And whether SE can /compile/ a script does not mean it can / execute/ a command, because compiling does not check the implementation of the various apps and extensions.
Sure.

Second problem: Did you define a template named "EndNote XML" the Template prefs? Because there does not exist one by default.
Yes, but I tried several variants, since BibDesk has AFAIK one file format called "EndNote XML" built in and offered for exporting via GUI. I tried that one as well, the one the "Save" commands is happy with. Mine is called "My EndNote XML". I tested the latter by giving it to the save command and it worked fine. Only export never works.

It always works for me. You just have to pass it a valid file object.


Third problems: "list thePubs" is not a valid reference, just evaluate thePubs or use "get" to get them if it does not work directly.
Ok. Thanks. But statements such as

set theOutFileID to open for access file theOutPFN with write permission
set eof theOutFileID to 0

You shouldn't open a file. And theOutFileID is an integer, not a file object, so it's wrong anyway.

tell application "BibDesk"
    set theBibDeskDocu to first document
    set thePubs to selection of theBibDeskDocu
export theBibDeskDocu to theOutFileID using template "My EndNote XML" for (get list thePubs)
end tell
close access theOutFileID

fails also miserably with error Can't get list {publications id "bdskidentifier://E99D..." of document "SomeRefs.bib"


Well, that's what I said. The 'list thePubs' makes no sense, that's a syntax error, why do you add the 'list'?



There might be an alternative approach by using a custom template

<?xml version=\"1.0\" encoding=\"UTF-8\"? >
<xml>
<records>
<$publications><$endNoteString/></$publications>
</records>
</xml>

and then using the first AppleScript

save theBibDeskDocu in file theOutPFN as "My EndNote XML"

Having installed in the "Template" preference of BibDesk above template as the main page under "My EndNote XML" for xml files. Above template works fine, but again, it exports all records. AFAIK I would need a "Collection modifier key" to export only the selection. Yet, BibDesk's help on this topic does no list any. Does anyone know whether it is possible to specify via above template such that only currently selected publications are exported? An if this is possible, does anyone know how the syntax of such a modification of this template would look like?


The save command always saves the whole document. That's what it is supposed to do. The "save" command is a standard command. Though it may be possible to change the template to only export the selection, it would be the wrong thing to do.
Why, if this is the only thing that might be possible or do you see a way how I could get the command export to do what I want?

Yes, the "export" command just works, you just need to do it right.


Thanks for your help and cooperation.

Sincerely yours,
Andreas Fischlin


You should just use the "export" command, passing the template you wrote above.

Ok I go along that route. However, note, before writing this reply I already tried another dozen variants and got none to work either (see one example above). If you know of any single variant in which the export command works, I would be very happy to learn about. Thanks.
You can pass the template either as an explicit string ('using text'), by file reference, or (when you've registered it) by name.
I have registered it, thus I tried by file reference the following legal AppleScript statements


See above why all these are wrong.

export theBibDeskDocu to theOutFileID using text "My EndNote XML" for (list thePubs)

... "using text" is used with the actual template string, not the name of a template.

export theBibDeskDocu to theOutFileID using template "My EndNote XML" for (list thePubs)

..this would work if you'd pass the correct file and publications arguments.

export theBibDeskDocu to file theOutFileID using text "My EndNote XML" for (list thePubs) export theBibDeskDocu to file theOutFileID using template "My EndNote XML" for (list thePubs)



but all fail, because the export command seems not to understand the file reference, since I get errors such as: BibDesk got an error: Cant make 53 into type file specifier or can't make 75 into type reference although I understand the first two to be exactly what you recommended.


Well, yea, an integer is not a file object...

Thus, I don't know how to accomplish this. BTW, I have tried about two dozens of formulations and none worked. It's a pity, since I expect this command to use really a lot. To open a new BibDesk document, then drag and drop just the publications I want to export, then export them all, then trow away that document seems to me to be really quite combersome, given there is command export (which seems not to work). If you know of any variant in which export works, I'm happy to start thinking differently. Thanks.

Regards,
Andreas


Basically, you have not learned how AppleScript handles basic file references. That has nothing to do with BibDesk. Why don't you look at sample script on the Wiki?

Christiaan


Christiaan

--
________________________________________________________________________
ETH Zurich
Prof. Dr. Andreas Fischlin
Systems Ecology - Institute of Integrative Biology
CHN E 21.1
Universitaetstrasse 16
8092 Zurich
SWITZERLAND
[email protected]
www.sysecol.ethz.ch/staff/af

+41 44 633-6090 phone
+41 44 633-1136 fax


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Bibdesk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-users

Reply via email to