• 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: lots of statements after "then" of "if"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >lots of statements after "then" of "if" (From: micro-people <email@hidden>)

  • Prev by Date: checking for characters
  • Next by Date: Re: Doubt
  • Previous by thread: Re: lots of statements after "then" of "if"
  • Next by thread: Re: lots of statements after "then" of "if"
  • Index(es):
    • Date
    • Thread