Can someone help me with this script??

Ok. The below script should work like this. In the application I’m using (Accordance), I have the ability to save Notes called User Notes. I want to be able to link from this program to other files on my computer.
For instance, I want to be able to highlight this in the user note—
path: accordance folder/studies/term paper
and then run my script. What I am expecting to happen is this piece of text be copied to the clipboard. Then I want the script to identify the ‘protocol’ at the beginning of this string, make the appropriate selection in the script, then tell finder to go open up the given file.

All of this works fine the first time that I run the script. The problem that I’m finding is that if I select a different protocol (string listed in my User Note) to go to a different file, the script just opens up the first file again. Its like it doesnt clear the clipboard and see the second file?? Is there a clear clipboard command that I could add into this that would fix my problem?? Any other suggestions on how to get this to work repeatedly and not just the first time?? Any help would be appreciated. Thanks
Heres the script…


property savesFolder : “Apple Drive”

try
alias savesFolder

on error
set savesFolder to (choose folder with prompt “Choose the folder to which all Path: references will provide a relative file path”) as string
end try

–testing parameters
tell application “Accordance 6.4.1”
activate
–delay 1
try
tell application “System Events”
tell process “Accord”
–delay 1
keystroke “c” using command down
delay 1 --give it time to update
set theString to (the clipboard)
end tell
end tell
on error
display dialog “You must activate GUI scripting in the Universal Access preferences pane of the Macintosh system preferences”
end try
end tell

set theProtocol to word 1 of theString
set n to (count of theProtocol) + 3
set theString to text n thru -1 of theString

if theProtocol is “URL” then
open location theString

else if theProtocol is “path” then
– the posix file path relative to the Saves folder must be specified
set thePath to (POSIX path of alias savesFolder) & theString
set theFile to POSIX file thePath
tell application “Finder” to open theFile

else if theProtocol is “file” then
– the full posix file path must be specified
set thePath to theString
set theFile to POSIX file thePath
tell application “Finder” to open theFile

else
display dialog “Sorry, something went wrong during parsing. Protocol not found. Make sure you’ve not highlighted extra characters, such as any brackets.”
end if

I think I’ve found this problem some times and I think it’s a bug. For a more robust behaviour, you may try some alternatives, such as copying to the clipboard yourself before running the script or creating a “service” using Bellhop: http://www.xendai.com/bellhop/index.html

Any other suggestions???