• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


  • Subject: Re: (no subject)
  • From: email@hidden
  • Date: Thu, 29 Jul 2004 11:23:26 -0400

Hey Everyone! I was just wondering what the format for a if-then script? I would like to ask a display a question and if they insert anything but the answer it asks the question again. How can I do this?

Consider placing the questioning 'display dialog' function within a handler. If the entered value does not match the expected answer - call the handler again.

Here are two quick examples:

01. For a single item to be compared to, consider ...

-- Created 29 Juli 2004. SJWL
-- 'Iteration_Single.scpt' - iterates a 'display dialog' until a predefined variable's value is entered.

global testValue
set testValue to "true"

set desiredResult to my getInfo()
display dialog "The entered text was: " & desiredResult buttons {"OK"} default button "OK"

on getInfo()
set theResult to display dialog "Enter needed Information: " default answer "" default button "OK"

-- If the entered text is anything but 'textValue' run 'getInfo()' again
if ((text returned of theResult) is not equal to testValue) then
my getInfo()
else
return testValue -- or 'return text returned of theResult'
end if
end getInfo

02. For a list of items to be compared to, consider ...

-- Created 29 Juli 2004. SJWL
-- 'Iteration_Multiple.scpt' - iterates a 'display dialog' until a value in a predefined list is entered.

global testValues
set testValues to {"Tom", "Dick", "Harry"}

set desiredResult to my getInfo()
display dialog "The entered text was: " & desiredResult buttons {"OK"} default button "OK"

on getInfo()
set theResult to display dialog "Enter needed Information: " default answer "" default button "OK"

-- If the entered text is anything but what 'testValues' contains run 'getInfo()' again
if (testValues does not contain text returned of theResult) then
my getInfo()
else
return text returned of theResult
end if
end getInfo

--

SJWL
_______________________________________________
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.


  • Prev by Date: Xserve and Dell KVM problems
  • Next by Date: Re: Date/time weirdness
  • Previous by thread: Re: repeat dialog (was (no subject))
  • Next by thread: (no subject)
  • Index(es):
    • Date
    • Thread