Hi Everyone! I just joined this Sibelius ManuScript Language list. Majordomo
says the lists hasn't been updated since July, 2002???? Can that be true? I'm just getting started with ManuScript and hope that someone can answer a couple of very basic questions. I'm using the ManuScript version that came with Sibelius v5.2 for x=1 to 5 { Sibelius.MessageBox(x); } The above will loop 4 times, not 5. The MessageBox displays the numbers, 1 to 4. No matter what I type for the upper limit, it always loops 1 less than that. How can something as basic as a 'for loop' not work correctly? My other question is about Sibelius.RandomNumber(). The Reference manual isn't very helpful here. Through a lot of trial and error I figured out it is producing the numbers 1 through 32,767. That's the limit for a signed integer. Is that correct? But the numbers it's producing are very UNrandom. Look at the following: z=0; y=0; Sibelius.RandomSeedTime(); for x=1 to 1000000 { z = Sibelius.RandomNumber(); If (z=1) { y=y+1; } } Sibelius.MessageBox(y); That should tell me how many times 1 occurs out of a million random numbers. However, I ran this program about a dozen times and the results are always 0 or 122. Nothing else. I also tried turning RandomNumbers into Notes this way... z = (z%12)+60; I thought that doing Modulo 12 would reduce the random numbers to 0 to 11 and then adding 60 would give me the MIDI notes Middle C to B above it. Instead I get patterns of 2 or 3 notes repeating over and over. There's an easy workaround for the 'for loop' problem, but not for the RandomNumber problem. Could someone please tell me how Sibelius.RandomNumber() works (or doesn't)? Many Thanks!  Karl7777 Your Email and More OntheGo. Get Windows Live Hotmail Free. Sign up now. 
Hi Karl,
The foor loop is designed this way, and is documented! Put the starting value zero: for i = 0 to 5 { etc; } This can be convenient because many things are counted from zero and there is a variable for the total number in that group. Most notably, arrays are counted from zero and the variable Array.NumChildren holds the total number of elements in the array, so we can do, for example: for i = 0 to Array.NumChildren { Sibelius.MessageBox(Array[i]); } And this will display every element of Array in order: For example if Array has 5 elements (that is Array.NumChildren equals 5) then it will display Array[0], ..., Array[4]. I looked into RandomNumber a while ago and determined that it is indeed not random but a rather ordinary pseudorandom. It was particularly bad if the seed was never set (that is a fresh Sibelius installation). My guess is it returns numbers from 0 to 32767. I found that after a couple of hundred goes (I don't know the exact number), the generated random numbers would just loop until the seed was reset again. This had the effect that the probability distribution was indeed not random but predefined (by the seed) and constant with respect to the sample size. By that I mean that some integers were never hit at all and ratio of the frequency of one integer to the frequency of another integer is constant if sample size is sufficiently big. So it seems that the random number generator in ManuScript is not good for big sample sizes but adequate for small sample sizes, provided that the seed is reset but possibly not too often. About a year after that, there was some discussion here about the random number generator but I didn't participate in it. Andrew 2010/1/4 karl malik <[hidden email]>

Hi Someone else can answer the random number stuff. It's been gone into before here so someone who learnt more from it than I did will be able to help. The loop is behaving as per the docs. It's useful if you want to count through the number if members in a zerobased group like an array, so you van just use the array's length as the limit and not fuss about it. You'll get used to it! It's in the docs, as I say. Neil  On Jan 4, 2010 9:56 AM, "Andrew Moschou" <[hidden email]> wrote: 
In reply to this post by karl malik
Karl7777,
the for loop does work correctly, in that it follows
the behaviour described in the reference. From 2.2
Loops:
*
* *
for x = 1 to 5
{
text = x & " potato,"; Sibelius.MessageBox(text); }
Here, the variable
x is stepped from the first value (1) up to the end value (5), stopping one step
before the final value.
*
* *
The random number generator is not a very good one. The
range is from 0 to 32768 but the integers are all multiples of 4.
Doing (Sibelius.RandomNumber() / 4) should ensure that
you get a complete filling of a smaller number space. I have no idea what the
pattern is (there will probably be one).
If you want random
numbers between 0 and 12 you could try:
for N = 0 to 100
{
X = Sibelius.RandomNumber() / 4;
Trace (X%12);
}
or:
Scale =
32768/12;
for N = 0 to
100
}
Trace
(Sibelius.RandomNumber() / Scale);
}
From past experience, the random numbers aren't that
random at all. You can do some mathematical tricks to try and force a little
more chaos into the system but it's a lot of work for not much
reward.
Hope this helps,
Dan
From: Majordomo Pseudo User
[mailto:[hidden email]] On Behalf Of karl malik
Hi Everyone! I just joined this Sibelius ManuScript Language
list. MajordomoSent: 04 January 2010 02:06 To: [hidden email] Subject: PLUGINDEV: 2 simple ManuScript questions says the lists hasn't been updated since July, 2002???? Can that be true? I'm just getting started with ManuScript and hope that someone can answer a couple of very basic questions. I'm using the ManuScript version that came with Sibelius v5.2 for x=1 to 5 { Sibelius.MessageBox(x); } The above will loop 4 times, not 5. The MessageBox displays the numbers, 1 to 4. No matter what I type for the upper limit, it always loops 1 less than that. How can something as basic as a 'for loop' not work correctly? My other question is about Sibelius.RandomNumber(). The Reference manual isn't very helpful here. Through a lot of trial and error I figured out it is producing the numbers 1 through 32,767. That's the limit for a signed integer. Is that correct? But the numbers it's producing are very UNrandom. Look at the following: z=0; y=0; Sibelius.RandomSeedTime(); for x=1 to 1000000 { z = Sibelius.RandomNumber(); If (z=1) { y=y+1; } } Sibelius.MessageBox(y); That should tell me how many times 1 occurs out of a million random numbers. However, I ran this program about a dozen times and the results are always 0 or 122. Nothing else. I also tried turning RandomNumbers into Notes this way... z = (z%12)+60; I thought that doing Modulo 12 would reduce the random numbers to 0 to 11 and then adding 60 would give me the MIDI notes Middle C to B above it. Instead I get patterns of 2 or 3 notes repeating over and over. There's an easy workaround for the 'for loop' problem, but not for the RandomNumber problem. Could someone please tell me how Sibelius.RandomNumber() works (or doesn't)? Many Thanks!  Karl7777 Your Email and More OntheGo. Get Windows Live Hotmail Free. Sign up now. 
In reply to this post by karl malik
karl malik wrote:
> for x=1 to 5 > { > Sibelius.MessageBox(x); > } > > The above will loop 4 times, not 5. The MessageBox displays the numbers, 1 to 4. This is an obscure feature of Manuscript. I can recommend to rewrite the above for loop as for x = 1 to 4+1 The +1 helps remind the programmer about the nonstandard behaviour; this is particularly useful when one writes also programs in other languages. HC 
Free forum by Nabble  Edit this page 