Help with recursion
Help with recursion
- Subject: Help with recursion
- From: Michelle Steiner <email@hidden>
- Date: Tue, 11 May 2004 17:33:48 -0700
set target_date to get_date()
log "target date is " & target_date
set today to (current date)
set time_remaining to target_date - today
set Weeks_remaining to (time_remaining / weeks) div 1
set days_remaining to ((time_remaining - (Weeks_remaining * weeks)) /
days) div 1 + 1
display dialog Weeks_remaining & " weeks, " & days_remaining & " days."
as text giving up after 5
on get_date()
set target to false
repeat until target is true
set target_date to text returned of (display dialog "enter the target
date" default answer "")
try
set target_date to date target_date
on error
get_date()
end try
set target to true
end repeat
return target_date
end get_date
If a correct entry is made the first time, the script works, but if
there is an error the first time, and the script gets another input,
the results of the first attempt are returned.
I see what the problem is; the incorrect entry is stored, and as the
recursive loop unwinds, the first entry is the one that remains.
How do I fix it?
-- Michelle
--
"The optimist proclaims that this is the best of all possible worlds ;
and the pessimist fears this is true." --James Branch Cabell
_______________________________________________
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.