Abby FineReader now has Applescript but can't get it to work

Hi,
Back in Nov 2014, Abbyy announced that their FineReader product is now applescriptable. See http://www.abbyy.com/news/ABBYY-FineReader-Pro-for-Mac-Now-Supports-Mac-OS-X-Native-Automation-Tools/
Their support also provided sample applescript code (see http://macscripter.net/viewtopic.php?id=43516) to control FineReader to automatically OCR - I had thought it would be relatively easy to modify it for Hazel but no...
Had struggled with this for 4 days but to no avail - I keep getting a error on "expected end but found no" at the WaitWhileBusy sub-routine. Please, what is wrong with this code so that I can use it as an embedded script within Hazel?
---
using terms from application "FineReader"
set langList to {English, German}
set saveType to single file
set retainLayoutWordLayout to as editable copy
set keepPageNumberHeadersAndFootersBoolean to yes
set keepLineBreaksAndHyphenationBoolean to yes
set keepPageBreaksBoolean to yes
set pageSizePageSizeEnum to automatic
set increasePaperSizeToFitContentBoolean to yes
set keepImageBoolean to yes
set imageOptionsImageQualityEnum to balanced quality
set keepTextAndBackgroundColorsBoolean to yes
set highlightUncertainSymbolsBoolean to yes
set keepPageNumbersBoolean to yes
end using terms from
WaitWhileBusy()
tell application "FineReader"
set hasdoc to has document
if hasdoc then
close document
end if
end tell
WaitWhileBusy()
tell application "FineReader"
set auto_read to auto read new pages false
end tell
tell application "Finder"
open theFile ¬
using application "FineReader"
end tell
delay 5
WaitWhileBusy()
tell application "FineReader"
export to pdf
end tell
WaitWhileBusy()
tell application "FineReader"
auto read new pages auto_read
close document
quit
end tell
on WaitWhileBusy()
repeat while IsMainApplicationBusy()
end repeat
end WaitWhileBusy
on IsMainApplicationBusy()
tell application "FineReader"
set resultBoolean to is busy
end tell
return resultBoolean
end IsMainApplicationBusy
Back in Nov 2014, Abbyy announced that their FineReader product is now applescriptable. See http://www.abbyy.com/news/ABBYY-FineReader-Pro-for-Mac-Now-Supports-Mac-OS-X-Native-Automation-Tools/
Their support also provided sample applescript code (see http://macscripter.net/viewtopic.php?id=43516) to control FineReader to automatically OCR - I had thought it would be relatively easy to modify it for Hazel but no...
Had struggled with this for 4 days but to no avail - I keep getting a error on "expected end but found no" at the WaitWhileBusy sub-routine. Please, what is wrong with this code so that I can use it as an embedded script within Hazel?
---
using terms from application "FineReader"
set langList to {English, German}
set saveType to single file
set retainLayoutWordLayout to as editable copy
set keepPageNumberHeadersAndFootersBoolean to yes
set keepLineBreaksAndHyphenationBoolean to yes
set keepPageBreaksBoolean to yes
set pageSizePageSizeEnum to automatic
set increasePaperSizeToFitContentBoolean to yes
set keepImageBoolean to yes
set imageOptionsImageQualityEnum to balanced quality
set keepTextAndBackgroundColorsBoolean to yes
set highlightUncertainSymbolsBoolean to yes
set keepPageNumbersBoolean to yes
end using terms from
WaitWhileBusy()
tell application "FineReader"
set hasdoc to has document
if hasdoc then
close document
end if
end tell
WaitWhileBusy()
tell application "FineReader"
set auto_read to auto read new pages false
end tell
tell application "Finder"
open theFile ¬
using application "FineReader"
end tell
delay 5
WaitWhileBusy()
tell application "FineReader"
export to pdf
end tell
WaitWhileBusy()
tell application "FineReader"
auto read new pages auto_read
close document
quit
end tell
on WaitWhileBusy()
repeat while IsMainApplicationBusy()
end repeat
end WaitWhileBusy
on IsMainApplicationBusy()
tell application "FineReader"
set resultBoolean to is busy
end tell
return resultBoolean
end IsMainApplicationBusy