Re: lots of statements after "then" of "if"
Re: lots of statements after "then" of "if"
- Subject: Re: lots of statements after "then" of "if"
- From: Christopher Nebel <email@hidden>
- Date: Tue, 9 Sep 2003 16:22:50 -0700
On Sep 9, 2003, at 7:19 AM, micro-people wrote:
my biggest wondering is "is there a way to do several things after
"then" of "if"
if yes would like to do some more complicated calculation and make the
song sound more funny
"if" can be followed by a block, like this:
if sarigama = 1 then
set pada to (26 + 12 * (random number from 0 to 3)) as text
set nisa to "[[pbas " & pada & "]]Sa"
end if
This is covered in the AppleScript Language Guide. Of course, as Mr.
Kaye points out, because your script is just using "sarigama" to select
a particular value, you can condense all the "if"s into two statements
that get an item from a list, like this:
set pada to ((item sarigama of {26,28,30,33,35}) + 12 * (random number
from 0 to 3))
set nisa to "[[pbas " & pada & "]]" & item sarigama of
{"Sa","Ri","Ga","Pa","Da"}
...and because the first one selects items that follow a simple
arithmetic progression, you could even not use a list:
set pada to (23 + sarigama * 3 + 12 * (random number from 0 to 3))
...but that's a matter of taste.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.