• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I get a script to ask me the number of times to repeat?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >How do I get a script to ask me the number of times to repeat? (From: Simon Kidd <email@hidden>)

  • Prev by Date: International number formats
  • Next by Date: Re: International number formats
  • Previous by thread: move / copy / duplicate
  • Next by thread: A question on System prefs
  • Index(es):
    • Date
    • Thread