Re: Asking User Input on First Run only
Re: Asking User Input on First Run only
- Subject: Re: Asking User Input on First Run only
- From: Kai Edwards <email@hidden>
- Date: Tue, 31 Dec 2002 03:02:30 +0000
on Tue, 31 Dec 2002 09:51:49 +1300, David Hood
<email@hidden> wrote:
>
On Monday, December 30, 2002, at 06:19 PM, Joseph Weaks wrote:
>
>
> What is a good method for asking for user input only the first time a
>
> script is run, after which the info (file locations) is saved in the
>
> script? Can I do this with properties?
>
>
It doesn't save the information in the script...
It should - as long as the script isn't recompiled. Try something like this:
===========================
property p1 : missing value
property p2 : missing value
property d0 : missing value
to getFileAliases()
try
return {p1 as alias, p2 as alias}
on error
firstRun()
error number -128
end try
end getFileAliases
on firstRun()
set {p1, p2, d0} to {getFile for 1, getFile for 2, current date}
end firstRun
to getFile for n
(choose file with prompt "Please choose file " & n) as string
end getFile
on doubleMod(d1, d2, f1, f2)
beep
display dialog [NO BREAK]
"Both files have been modified since the last update." & [NO BREAK]
return & return & "Update the older file anyway?" with icon 2
if d1 > d2 then
dupeMod on d1 from f1 to f2
else
dupeMod on d2 from f2 to f1
end if
end doubleMod
on noMod()
display dialog "Neither file has been " & [NO BREAK]
"modified since the last update." buttons [NO BREAK]
"Cancel" default button 1 with icon 0
end noMod
to dupeMod on d from src to tgt
display dialog "Source file: " & return & src & return & [NO BREAK]
return & "Target file: " & return & tgt & return & [NO BREAK]
return & "OK to duplicate source to target file?" with icon 1
tell application "Finder" to [NO BREAK]
duplicate src to tgt's container with replacing
set d0 to d
end dupeMod
set {f1, f2} to getFileAliases()
tell application "Finder" to set {d1, d2} to [NO BREAK]
{f1's modification date, f2's modification date}
if d1 > d0 then
if d2 > d0 then
doubleMod(d1, d2, f1, f2)
else
dupeMod on d1 from f1 to f2
end if
else
if d2 > d0 then
dupeMod on d2 from f2 to f1
else
noMod()
end if
end if
===========================
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.