RE: How to prompt for multiple values (and verify them) from Inst
RE: How to prompt for multiple values (and verify them) from Inst
- Subject: RE: How to prompt for multiple values (and verify them) from Inst
- From: Ed Walter <email@hidden>
- Date: Fri, 7 Feb 2003 11:41:35 -0600
Joseph,
I just typed this in my email client, so it hasen't been tested, but it
should give you a general idea of how to build a validation handler:
set validFlag to false
set usrMsg to "Enter number here:"
repeat while not validFlag
set usrText to (text returned of (display dialog usrMsg default answer
"8080"))
try
set usrItems to {}
set {validFlag,usrItems} to validateUsrText(usrText)
end try
if not validFlag then
set oldTIDs to applescript's text item delimiters
set applescript's text item delimiters to return
set errItems to usrItems as string
set applescript's text item delimiters to oldTIDs
set usrMsg to "The following items were invalid:" & return &
errItems
end if
end repeat
on validateUsrText(usrText)
set oldTIDs to applescript's text item delimiters
set applescript's text item delimiters to " " -- assuming space
delimited items
set usrItems to every text item of usrText
set applescript's text item delimiters to oldTIDs
if count usrItems < 3 then return {false,{"Not enough items"}} --
assuming 3 items
if count usrItems < 3 then return {false,{"Too many items"}} --
assuming 3 items
-- the following would need to be your logic
set errItems to {}
if not ((item 1 of usrItems as number) > 9) and ((item 1 of usrItems
as number) < 1000) then
set errItems to errItems & "Item 1"
end if
if not ((item 2 of usrItems as number) > 99) and ((item 1 of
usrItems as number) < 1000) then
set errItems to errItems & "Item 2"
end if
if not ((item 3 of usrItems as number) > 999) and ((item 1 of
usrItems as number) < 10000) then
set errItems to errItems & "Item 3"
end if
if count errItems > 0 then
return {false,errItems}
else
return {true,usrItems}
end if
end validateUsrText
Hope it helps!
-ed-
-----Original Message-----
From: Joseph Silverman [
mailto:email@hidden]
Sent: Friday, February 07, 2003 10:48 AM
To: Ed Walter
Subject: Re: How to prompt for multiple values (and verify them) from
Inst
How would I extend that to do more than one value in the dialog? I
need to prompt for as many as three different port numbers - would
rather not bring up three dialogs. I realize this will complicate
things a bunch. Cheers and thanks - Yossie
On Friday, February 7, 2003, at 06:32 AM, Ed Walter wrote:
>
Something like this should work:
>
>
set usrNumber to 0
>
set usrMsg to "enter a number"
>
repeat while usrNumber < 100 or usrNumber > 10000
>
set usrText to (text returned of (display dialog usrMsg default
>
answer "8080"))
>
try
>
set usrNumber to usrText as number
>
end try
>
set usrMsg to "Value must be between 100 and 10,000"
>
end repeat
>
>
-ed-
>
>
>
-----Original Message-----
>
From: Joseph Silverman [mailto:email@hidden]
>
Sent: Thursday, February 06, 2003 10:40 AM
>
To: email@hidden
>
Subject: How to prompt for multiple values (and verify them) from
>
Installer?
>
>
>
I would like to create a Package that, when Installed, would be able to
>
prompt for a few numeric values in a specific range (TCP/IP port
>
numbers, actually) during the postflight stage of the install. These
>
would then be used to modify the installed files as necessary. I can
>
do ONE value with:
>
>
value=`osascript -e 'tell application "Installer"
>
display dialog "enter a number" default answer "8080"
>
returned text of the result
>
end tell' i 2>/dev/null || echo DEFAULT-ANSWER`
>
>
This doesn't verify the result is numeric or in range, which I could
>
readily add in shell but am not sure how to do it in AppleScript.
>
>
So, my question is, How do I do this?
>
>
Thanks - Yossie
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.