Randomly Generated Script

Sorry for the revisiting an old topic, however I'm highly interested in this function but don't full understand it. I do understand that I don't need a deep understanding of it to apply it to my macro.

I've created a group of pause macro's ranging from .1-.99 seconds, and if I understand correctly this should allow me to somewhat "randomly" pull from that group. What I'm not understanding is the "Input from Text" field. Is this shell script "looking" through my macros names, and selecting one (more or less at random) that has a name matching from the "input from text" field?

Another way to phrase my lack of understanding, do I need to set a "group"/ destination for it to search through?

I hope that makes sense. I can post my macro if that helps, but it seems rather a lack of understanding the functionality of the shell script as the rest of my macro functions properly aside from adding in this "randomized pause" function.


1 Like

What do these "pause macros" do? Can you simplify it right down and just use one macro -- or even a single action in your main -- that uses RAND in a "Pause" action? Even if they do different things there's probably a limited number of differences, so you could RAND the pause and then "Switch/Case" through different branches depending on that value.

I did a bit of research myself, and stumbled across RANDOM(a,b). RAND was insufficient because I wanted a/b to be tenths of a second, or a real number as opposed to RAND(a,) offering whole numbers. RANDOM(a,b) was able to work for my needs. I was originally trying to use a group of macros that all were a pause with varied lengths, and like you mentioned, I was able to solve it with a single pause utilizing RANDOM(A,B). Thanks for the help!

I'd still use RAND(A,B) myself, as in RAND(10,99) / 100 to get 0.10 - 0.99 in 100ths of a second (I know you said 10ths, but your inclusion of 0.99 confuses the issue -- should that become 0.9 or 1.0?).

That's partly habit, partly readability, but mainly concerns about boundary values and frequencies. While RAND(A,B) includes B, RANDOM(A,B) doesn't -- if you want to include 0.99 then B has to be 0.99000001 (I think!).

And it then depends on how you are getting from your 8 decimal place random number to your 2 decimal place value. For example, if rounding "as taught at school" (as AppleScript describes it) you actually have to do RANDOM(0.05,0.995) to get the correct frequencies for your boundary values -- suddenly the numbers are more complicated and you have to know whether you're rounding/flooring/truncating/whatever to make sense of the code.