Re: Exiting a repeat loop if not false
Re: Exiting a repeat loop if not false
- Subject: Re: Exiting a repeat loop if not false
- From: kai <email@hidden>
- Date: Thu, 25 May 2006 18:06:18 +0100
On 25 May 2006, at 12:34, Jay Louvion wrote:
The following works only if I get it right the first time (entering
123, for ex.); If I type a false answer, i.e. “qwertz”, the repeat
loop never exits, even when entering a correct answer afterwards.
Is there a simpler way of doing this ?
set AllowExit to true
repeat
set OrderNum to ""
set OrderNum to text returned of (display dialog "Numéro de la
commande (sans le \"LG\") ?" default answer "")
try
set OrderNum to (OrderNum as integer)
on error
set AllowExit to false
end try
if AllowExit is true then exit repeat
end repeat
Another way to achieve something similar, Jay, is to use an error to
simply exit the try statement before the 'exit repeat' statement is
reached. (It might also be worth considering an additional statement
to check for an empty entry.)
------
repeat
set OrderNum to text returned of (display dialog "Numéro de la
commande (sans le \"LG\") ?" default answer "")
if (count OrderNum) > 0 then try (* entry was not empty *)
set OrderNum to OrderNum as integer
exit repeat
end try
end repeat
------
---
kai
_______________________________________________
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