dialog box asking for various input

first thing i want my script to do is to open a dialog box asking:

  1. for input in a one line text box (this is saved as one variable)
  2. for input in another one line text box (that is then saved as another variable)
  3. four options (radio buttons if you will or something) that let user select one option only (lets name them clinet1, client2, client3, clinet4) - each of those are yet separate variables

all three go on the same dialog box
then the script continues using the variables assigned above

thank you


set mainList to {"Clinet1", "Clinet2", "Clinet3", "Clinet4"}
choose from list mainList with prompt "Choose Clinet"
set listchoice to result as text

That will get you

as for

I don’t think you can have more than one “user input field” in a dialog box. You’re prolly going to have to settle for prompt 1, prompt 2, and then the code above as prompt 3.
Comments, anyone?
SC

:idea: I have your request narrowed down to 2 dialog boxes. We definitely can’t have two text entry fields in one dialog box. You would need another program to customize that. There is a way around this…
Using text item delimiters, you can request multiple text variables in one field, as many as you like, in theory.
If you set the delimiter to a comma, your dialog box would pop up asking:
Enter variable1 and variable2 separated by “,” (or whatever you set the delimiter to)
Enter the two text items, separate them with a comma, and there are your two text variables entered with one dialog box. I combined that with the previous script to give you your variable returns from 2 pop up boxes. Best I can do.
SC


set temp to display dialog "Enter a 'date' and 'invoice number' separated by a comma, as an example of two variables input in one dialog box" default answer ""
set text_user_entered to the text returned of temp
set old_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}
set variable1 to the first text item of text_user_entered
set variable2 to the second text item of text_user_entered
set AppleScript's text item delimiters to old_delimiters
set mainList to {"Clinet1", "Clinet2", "Clinet3", "Clinet4"}
choose from list mainList with prompt "Choose Clinet"
set listchoice to result as text

display dialog "Here you can see all your variables returned: " & variable1 & ", " & "#" & variable2 & ": " & listchoice

Please complete this post by letting us know if this helps! :smiley:

Sitcom is right: the AS standard dialogs won’t allow more than one text field and three buttons. If you want something more sophisticad you should try AppleScript Studio which allows you to create interfaces without these restrictions.

Good work
Farid

If you’re concerned about getting up to speed on AppleScript Studio to create your interfaces, there is a scripting addition that adds more options for dialogs (among other things). Appearance OSAX 3.0 by 24U Software.

http://www.24usoftware.com/AppearanceOSAX

Building a script that depends on a scripting addition may add concerns about portability, but if you have access to the machine(s) that will run it this could be another option for you.

I’ve been leaning on this OSAX pretty heavily and have not been disappointed. When I get the time to shift gears I plan to convert things over to AppleScript Studio projects.

Mark

thanks for the info, I ended up going with the first option

one more question, can you preset one of those entries from the list to be preselected when the box opens? Sort of like default answer option for a regular input dialog box.

thanks

Not that I am aware of. Only the “Display dialog” box gets to use “default”. However, if you want to have one of them be the default, try this: When the dialog prompt comes up, asking for the 2 variables, if you have a default “Clinet”, that’s where your “Default button” would be. ie,

set listchoice to “DefaultClinet”–here you set the default choice
dialog to enter your two variables with
buttons {“Choose Clinet”, “Default Clinet”} default button “Default Clinet”

Then you’ll never see the list because you just chose the default. The other option sends you to the list choices.


set listchoice to "Default Clinet"
set UI1 to display dialog "Enter a 'date' and 'invoice number' separated by a comma, as an example of two variables input in one dialog box" default answer "" buttons {"Choose Clinet", "Use default Clinet"} default button "Use default Clinet"
set text_user_entered to the text returned of UI1
set button_name to button returned of UI1

set old_delimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {","}
set variable1 to the first text item of text_user_entered
set variable2 to the second text item of text_user_entered
set AppleScript's text item delimiters to old_delimiters

if button_name is "Choose Clinet" then
	set mainList to {"Clinet1", "Clinet2", "Clinet3", "Clinet4"}
	choose from list mainList with prompt "Choose Clinet"
	set listchoice to result as text
end if

display dialog "Here you can see all your variables returned: " & variable1 & ", " & "#" & variable2 & ": " & listchoice

SC

Is this what you mean?

set mainList to {"Clinet1", "Clinet2", "Clinet3", "Clinet4"}
set listchoice to ¬
	(choose from list mainList with prompt ¬
		"Choose Clinet" default items {item 2 of mainList}) as text

– Rob

that’s exactly it

thanks for help, all of you