Random Interger

OscariBot

Active member
Am trying to load a variable with a random number 1 - 12. Ofcouse this is very possible as u can see from the screenshot below... But how do you replace the 1 and 12 with a magic text?
I try using Expression but but no luck.
 

Attachments

  • Screenshot_20230223-223847.jpg
    Screenshot_20230223-223847.jpg
    185.6 KB · Views: 2

Dm114

Well-known member
Am trying to load a variable with a random number 1 - 12. Ofcouse this is very possible as u can see from the screenshot below... But how do you replace the 1 and 12 with a magic text?
I try using Expression but but no luck.
Use Random() fonction instead
 

Dimlos

Well-known member
This is a shell script, so some devices may not work well.
Please forgive the two actions since the output is a string variable.
 

Attachments

  • Macro.jpg
    Macro.jpg
    487.6 KB · Views: 16
  • Random_Integer.macro
    3.5 KB · Views: 5

Dm114

Well-known member
Can I use Magic Text? I tried it and it did not work. I would appreciate it if you could upload a sample macro.
No you cannot seed Random function: it has no argument.
It's up to you to transform the result according to your boundaries.

Let me a few minutes to write a short macro for you...
 

Dimlos

Well-known member
If the seed is not generated by RANDOM, awk's limitation will generate the same random number when called within 1 second.
I use RANDOM to avoid this.

If I simply used RANDOM(), I could not generate a random number.
 

Attachments

  • RANDOM().jpg
    RANDOM().jpg
    305.9 KB · Views: 12
  • Caution.jpg
    Caution.jpg
    331.9 KB · Views: 12

Dm114

Well-known member
If the seed is not generated by RANDOM, awk's limitation will generate the same random number when called within 1 second.
I use RANDOM to avoid this.

If I simply used RANDOM(), I could not generate a random number.
Use this Set variable action
(RANDOM()*[lv=max])+1
 

Dimlos

Well-known member
Use this Set variable action
(RANDOM()*[lv=max])+1
I feel that the results are inferior to MacroDroid's standard random because it does not always start with 1 or 0.
I am making it so that I can specify a minimum and maximum value in awk.
Isn't that what @OscariBot is looking for?
 

Dm114

Well-known member
I feel that the results are inferior to MacroDroid's standard random because it does not always start with 1 or 0.
I am making it so that I can specify a minimum and maximum value in awk.
Isn't that what @OscariBot is looking for?
Random number is a decimal number 0<d<1
 

Dimlos

Well-known member
In MacroDroid, I can easily specify a minimum value, and my script does the same thing.
But I can't do it with the answer provided. Is it because that answer is different from the definition of a random number?
So you're saying it's incomplete or you should just give up?
 

Attachments

  • MDRandom.jpg
    MDRandom.jpg
    283.1 KB · Views: 4

OscariBot

Active member
Thanks for all ur contributions... But all I needed is a simple random integer generator.

I really wonder why MD didn't recognize my expression below...

RANDOM([lv=dic1],[lv=dic2])

see the screenshot below the "OK" button is ghosted meaning MD didn't recognize it. What is wrong with this expression?
 

Attachments

  • Screenshot_20230225-081733.jpg
    Screenshot_20230225-081733.jpg
    153.3 KB · Views: 5

Dimlos

Well-known member
I don't know what's in the local variables, and I don't really understand what you are trying to do.
 

Dimlos

Well-known member
I can only say that it is because the syntax and content are wrong.
If you knew what you wanted to randomize and how, you might be able to find a workaround, but as it is now, no one will be able to give you the answer you want.
 

OscariBot

Active member
Like i said earlier am looking for a very simple way to generate random integer numbers between lv1 and lv2
The local variables contain the min and max numbers.

I hop u got a clear explanation.

By the way wat is the use of the RANDOM () Expression?

I thought I could use the expression below to generate random numbers between 1 and 12
RANDOM([lv=dic1],[lv=dic2])
The local variables hold the min and max number and ofcuz they are intergers
 
Top