Since the pattern of T and S in a major scale is not easily obtained by a mathematical formula, it's best just to store it in a table. Here's an example using the numbering system 0,2,4,5,7,9,11. Just add 1 to that to get your numbering system. The example also includes a formula to generate a stack of fifths in Lydian mode, which you can convert into an out-of-order C major scale, but the table lookup method is more efficient and straightforward. Add some whole-number multiple of 12 to transpose these pitches to different octaves, and add some number of semitones to transpose to a different key.
you want [random] to make random index numbers, which look up the scale degrees you want, rather than try and generate the numbers themselves. Then you can load a [umenu] or other list-based data structure (table, multislider, etc.) with as many scales as you want:
(edit: zl lookup eliminated a half-dozen objects in my original patch...doh :)