If the default answer of a dialog
contains a return, then you can +use a return in the answer+ (in this case, the return
key won't be used for the default button, although the enter key will still be used). Going a little bit further than casdvm, but using the same idea (using a return as a delimiter between items), you can fake a multiple input dialog. I have a general purpose handler that will get multiple input items (it is a bit long but has a lot of options):
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
set {Slot, Course} to (InputItems for {"• Class slot", "• Course"} with Prompt given Title:"Data Entry")
display dialog "Slot: " & (quoted form of Slot) & return & "Course: " & (quoted form of Course) with title "results"
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 separated by returns:" & 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) -- with icon caution with hidden answer)
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
</pre>
If you are looking at easier error handling or an entry box for each item, then yes, AppleScript Studio is what you want.
Message was edited by: red_menace