AppleScript that branches depending on AppleScript version?

In another thread, Shane Stanley posted a brilliant AppleScript that creates a PDF from any file that TextEdit can open, and I will use it as a function in an AppleScript application I am working on.

But I have one question: the script requires AppleScript 2.4 (in effect, that means OS X 10.10). Is there any way to build a script that (1) includes this function that requires AppleScript 2.4 and (2) will run under older versions and display a message saying that this function requires a more recent version? In other words, is it possible to write an AppleScript in which a function will run under recent versions but do something else under older versions?

I doubt this is possible, but AppleScript is always surprising me with what it can do, so I thought it would not hurt to ask.

P.S. After posting this, it occurred to me that it might be possible to do this by creating an AppleScript that requires AppleScript 2.4, and enclosing it inside an application bundle - and then, if the required OS version is found, run that script from the main script. Does this idea make sense? (Meanwhile, I’ll try it.)

It will actually run under 10.9, but you have to call it via a script library there.

The bundled script idea might work, but maintaining backwards compatibility is usually a pain. I reckon separate apps is a better proposition.

OK, a script library sounds like the way to go. Presumably an AppleScript that uses a script library will run under OS X 10.9 and later versions also?

Also, while I am exploiting your knowledge, how much of this code would be required in the library:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

Thank you again!

Just change the 2.4 to 2.3.

Thank you!

A few hours ago I posted a message asking for your help in making this work using a Script Library. I deleted the message because I eventually figured it how to do it. Thank you again!