Re: How do I get a script to ask me the number of times to repeat?
Re: How do I get a script to ask me the number of times to repeat?
- Subject: Re: How do I get a script to ask me the number of times to repeat?
- From: Brennan <email@hidden>
- Date: Fri, 25 Feb 2005 12:53:24 +0100
On 24/2/05 at 13:44, Simon Kidd <email@hidden> wrote:
> Hi,
>
> Iam trying to write a script which goes through a folder and moves
> every nth (second, third, or fourth and so on) item to a new folder.
> I think Iam going to use GUI scripting to select the item to move but
> I would like the script to ask how many times it is to repeat and in
> what phase it is to select items. So my question is what is the
> command I need to script to have the script ask me these questions?
Not sure if it will help, but here is a snippet I use all the time:
on integerFromUser(thePrompt, defaultValue)
set fullPrmpt to thePrompt
repeat while true
set dr to (display dialog fullPrmpt default answer defaultValue)
try -- to coerce to integer
set wi to (the text returned of dr) as integer
if class of wi is integer then -- everything worked out
return wi
end if
on error msg number num
if num is -1700 then -- coercion to integer failed
set fullPrmpt to thePrompt & "
Please use only numerical characters!"
else
if num is not -128 then -- something other than user pressing 'cancel'
display dialog msg buttons {"Rats"} default button 1
end if
error number -128 -- abort entire script
end if
end try
end repeat
end integerFromUser
-- example call:
set i to integerFromUser("Enter an integer", 256)
return i
Brennan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden