Re: Optional Parameter in Handler
Re: Optional Parameter in Handler
- Subject: Re: Optional Parameter in Handler
- From: John Delacour <email@hidden>
- Date: Thu, 21 Nov 2002 23:15:37 +0000
- Mac-eudora-version: 5.3a9
At 3:46 pm -0600 21/11/02, Ed Walter wrote:
Has anyone come up with a good way to have an optional parameter in a
handler?
Such as:
----------------------------------------------------
Property methodList:{"Peace","Love","Understanding"}
on saveWorld(Command,methodList)
Why not pass a single argument as a list and let the handler work
things out? The use of a record in the script below is simply to aid
the memory.
set rec_ to {operation:"mul", num1:82, num2:3, num3:4, num4:2}
CALCULATE_(rec_ as list)
-- or simply CALCULATE_({"mul", 82, 3, 4, 2})
on CALCULATE_(ARGV)
set n to item 2 of ARGV
if item 1 of ARGV is in "multiply" then
repeat with i from 3 to count ARGV
set n to n * (item i of ARGV)
end repeat
else if item 1 of ARGV is in "divide" then
repeat with i from 3 to count ARGV
set n to n / (item i of ARGV)
end repeat
end if
n
end CALCULATE_
-- JD
_______________________________________________
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.