Re: multi input form
Re: multi input form
- Subject: Re: multi input form
- From: Deivy Petrescu <email@hidden>
- Date: Mon, 08 Mar 2010 20:34:21 -0500
On 08/03/2010, at 19:54 , red_menace wrote:
>
> For a "pure" AppleScript solution, you can use the feature of a dialog box that
> using returns in a default answer will let you use returns in the answer without
> triggering the default button.
>
> To actually use multiple input text fields you will need to use one of the other
> recommended methods, but to just get multiple input items from the standard
> display dialog you can use something like:
>
>
> -- multiple input dialog
>
> on run -- example
> set {firstName, lastName} to (inputItems for {"• First Name", "• Last Name"} with title given prompt:"Enter the following items separated by a carriage return:")
> display dialog "First Name: \"" & firstName & "\"" & return & "Last Name: \"" & lastName & "\""
> end run
>
> to inputItems for someItems given title:theTitle, prompt:thePrompt
> (*
> displays a dialog for multiple item entry - a carriage return is used between each input item
> for each item in someItems, a line of text is displayed in the dialog and a line is reserved for the input
> the number of items returned are padded or truncated to match the number of items in someItems
> to fit the size of the dialog, items should be limited in length (~30) and number (~15)
> parameters - someItems [list/integer]: a list or count of items to get from the dialog
> theTitle [boolean/text]: use a default or the given dialog title
> thePrompt [boolean/text]: use a default or the given prompt text
> returns [list]: a list of the input items
> *)
> if thePrompt is in {true, false} then -- "with" or "without" prompt
> if thePrompt then
> set thePrompt to "Input the following items:" & return & return -- default
> else
> set thePrompt to ""
> end if
> else -- fix up the prompt a bit
> set thePrompt to thePrompt & return & return
> end if
>
> if theTitle is in {true, false} then if theTitle then -- "with" or "without" title
> set theTitle to "Multiple Input Dialog" -- default
> else
> set theTitle to ""
> end if
>
> if class of someItems is integer then -- no item list
> set {theCount, someItems} to {someItems, ""}
> if thePrompt is not "" then set thePrompt to text 1 thru -2 of thePrompt
> else
> set theCount to (count someItems)
> end if
> if theCount is less than 1 then error "inputItems handler: empty input list"
> set {theItems, theInput} to {{}, {}}
>
> repeat theCount times -- set the number of lines in the input
> set the end of theInput to ""
> end repeat
> set {tempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
> set {someItems, theInput} to {someItems as text, theInput as text}
> set AppleScript's text item delimiters to tempTID
>
> set theInput to paragraphs of text returned of (display dialog thePrompt & someItems with title theTitle default answer theInput)
>
> repeat with anItem from 1 to theCount -- pad/truncate entered items
> try
> set the end of theItems to (item anItem of theInput)
> on error
> set the end of theItems to ""
> end try
> end repeat
> return theItems
> end inputItems
>
>
> Also see http://macscripter.net/viewtopic.php?id=24707
>
Nice work around!
Deivy Petrescu
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden