Due do my recent loosing of 70+ pages of writing, I decided to write a script to autosave pages for me. It may look a little flawed (only saves one document at a time), but I have written this for my needs, exactly how I want it to work. Unfortunately, it gets an error every time
it says it "cannot get document (name of document typed) of application "pages"
please help me with this

Code:
set xyz to text returned of (display dialog "Enter name of document to autosave" default answer "" buttons {"OK"} default button "OK")
set uptime to 0
repeat
delay 60
set uptime to uptime + 1
if uptime ≥ 5 then
tell application "Pages"
save document xyz
display alert "Autosaved"
end tell
set uptime to 0
end if
end repeat
please help me with this
