Hi
I have a script that works Ok as a script but when I save it as an application it does not complete. I have built in various delays and Dialog Boxes so I can track the operation. It stalls (as an application) when it gets to the subroutine " on FileNameAddition" It shows the dialog box and hangs and does not get back to the main routine.
This is the script
--To Select a destination for QS Back up
--To Select the original QS Database File
--To Back up the Selected file to the Destination afetr adding an extension based on date/time
--To Open the original file for Processing
--
set BUFolderName to {} --BackUp Destination
set QSFile to {}
set QSName to {}
set QSExtention to {}
set QSDupe to {}
global FileNameAddition_
tell application "Finder"
--Choose Backup Destination
set note1 to "
You will first be asked for the folder to save the backup to,
then for the file you are going to open and backup.
As of 4/25/2017 the backups were stored in My Cloud.
This will appear as a shared device WDMYCloud"
display dialog note1
set BUFolderName to choose folder "Choose Folder for Back up of the QS Database File"
delay 3 --At present using WDMyCloud which needs time to open
--Choose QS File
set QSFile to choose file "Choose the QS Database File to be processed"
set QSName to name of QSFile
set QSExtention to name extension of QSFile
--Return Just the File Name with out extension
set QSName to characters 1 through (((count characters in QSName) - (count characters in QSExtention)) - 1) of QSName
delay 2 --Added as kept getting an error did not understand following command with some files
display dialog "Will now Rename File for BackUp"
my FileNameAddition_()
set QSName to QSName & " " & FileNameAddition_ & "." & QSExtention as text
set QSDupe to duplicate QSFile to BUFolderName --Duplicates theoriginal file to the Back up Folder
set name of QSDupe to QSName --Renames the file copied to the Back up Folder
--Open the original File
display dialog "Now Opens Original Database File following BackUp"
open QSFile
end tell
on FileNameAddition_() --Create File NameAddition
tell me
activate
display dialog "Create Backup Name will delay 2 seconds"
end tell
delay 2
set myhour to get the (hours of (current date)) as string
set mymin to get the (minutes of (current date)) as string
set mymonth to get the (month of (current date)) as integer
set mymonth to mymonth as string
set myday to get the (day of (current date)) as string
--Pad Results so always a four digit number
if (length of myhour) < 2 then set myhour to "0" & myhour
if (length of mymin) < 2 then set mymin to "0" & mymin
if (length of mymonth) < 2 then set mymonth to "0" & mymonth
if (length of myday) < 2 then set myday to "0" & myday
set FileNameAddition_ to mymonth & myday & " " & myhour & mymin
end FileNameAddition_
Any suggestions appreciated
thanks
peter
Model: iMac 27
Browser: Safari 603.1.30
Operating System: Mac OS X (10.10)