Re: Propmpting user to enter Variables
Re: Propmpting user to enter Variables
- Subject: Re: Propmpting user to enter Variables
- From: Matthew Smith <email@hidden>
- Date: Sat, 14 May 2005 02:06:56 +1000
on 14/05/2005 01:36, francois.houle at email@hidden wrote:
> Hi,
>
> I have four variables that the user gets prmpted for when a script begins...
> However I have added a section aftet hat to check if any of the fields are
> left empty, and if so it would offer then to either cancel the script or try
> to enter the variables again...
> For now it looks like this:
>
> Set variable_1 to the text returned of (display dialog "enter this info
> here" default answer "" with title "This info")
> Set variable_2 to the text returned of (display dialog "enter that info
> here" default answer "" with title "That info")
> Set variable_3 to the text returned of (display dialog "enter this info 2
> here" default answer "" with title "This info 2")
> Set variable_4 to the text returned of (display dialog "enter that info 2
> here" default answer "" with title "That info 2")
>
> set variable_list to {variable_1, variable_2, variable_3 variable_4}
> if items of variable_list contains "" then
> display dialog "Error: One or more of the fields was left blank. The
> script cannot be executed" buttons {"Cancel", "Retry"} default button 2
> if button returned of result is "Cancel" then
> quit script
> else if button returned of result is "Retry" then
> ... <- Missing part !
> end if
> end if
>
> Just can't find how to re-prompt the user to enter those variables... And
> obviously they would need to get the Error prompt on any attemp...
You need to wrap each one in a repeat loop.
For example:
Set variable_1 to my userinput("enter this info here", "", " This info")
Set variable_2 to my userinput("enter that info here", " This info")
Set variable_3 to my userinput("enter this info 2 here", "", " This info 2")
Set variable_4 to my userinput("enter that info 2 here ", "", " That info
2")
on userinput(msg, defaultValue, theTitle)
set ret_value to ""
set msg1 to msg
repeat until variable_1 ""
set ret_value to the text returned of (display dialog msg1 default
answer defaultValue with title theTitle)
if ret_value = "" then
set msg1 to "You must enter a value to continue." & return & msg
end if
end repeat
return ret_value
end userinput
> I want to have an equivalent to
>
> "set scripts_folder to (path to scripts folder from user domain with folder
> creation) as string"
>
> But for the StartupItems folder in the user's Library folder. I just can't
> figure out how to do it since its not one of the AppleScript "mapped"
> folders.
There is no StartupItems folder in the user's Library folder? You could
create one but it has no function. There's one in the Library folder at the
top level of the system volume, and another in the Library folder of the
System folder.
You can get the user's library folder with:
path to library folder from user domain
You can then append to that path anything you want.
--
Matthew Smith
_______________________________________________
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