Or are you telling me that the rich text is always created on the fly when opening a compiled file as the code you sent yesterday seemed to suggest ?
Yes. AppleScript uses the script, which contains four-letter codes for all the terminology, plus the dictionaries of any apps, libraries and scripting additions addressed to find out what those codes stand for, and then generates the source you see.
An attributed string can be converted to rtf simply enough. But it's not *extracting*, it's *generating*.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file) -- chose script
set theDest to POSIX path of (path to desktop) & "Test.rtf"
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set {theScript, errorDict} to current application's NSAppleScript's alloc()'s initWithContentsOfURL:theURL |error|:(reference)
if theScript is missing value then error (errorDict's |description|() as text)
set styledSource to theScript's richTextSource()
set theRTF to styledSource's RTFFromRange:{0, styledSource's |length|()} documentAttributes:(missing value)
theRTF's writeToFile:theDest atomically:true