Sunday, December 5, 2021

#1 2005-04-15 10:48:24 am

pelachrum
Member
Registered: 2005-04-11
Posts: 45

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

Offline

 

#2 2005-04-15 11:22:10 am

sitcom
Member
Registered: 2005-03-14
Posts: 367

Re: dialog box asking for various input

Applescript:


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

a dialog box asking four options (radio buttons if you will or something) that let user select one option only (lets name them clinet1, client2, client3, clinet4)


as for

all three (inputs) go on the same dialog box


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

Offline

 

#3 2005-04-15 08:50:40 pm

sitcom
Member
Registered: 2005-03-14
Posts: 367

Re: dialog box asking for various input

: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

Applescript:


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! big_smile

Offline

 

#4 2005-04-17 04:15:21 am

chebfarid
Member
From:: Milan / Italy
Registered: 2003-04-26
Posts: 76

Re: dialog box asking for various input

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

Offline

 

#5 2005-04-19 08:15:03 am

mleslie
Member
From:: indoors
Registered: 2005-02-09
Posts: 61

Re: dialog box asking for various input

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

Offline

 

#6 2005-05-05 04:54:03 pm

pelachrum
Member
Registered: 2005-04-11
Posts: 45

Re: dialog box asking for various input

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

Offline

 

#7 2005-05-05 06:14:07 pm

sitcom
Member
Registered: 2005-03-14
Posts: 367

Re: dialog box asking for various input

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.


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.

Applescript:


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

Offline

 

#8 2005-05-05 07:40:42 pm

Rob
Member
From:: Ohio, USA
Registered: 2002-11-20
Posts: 1886

Re: dialog box asking for various input

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.



Is this what you mean?

Applescript:

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

Offline

 

#9 2005-05-05 08:04:15 pm

pelachrum
Member
Registered: 2005-04-11
Posts: 45

Re: dialog box asking for various input

that's exactly it

thanks for help, all of you

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)