Page 1 of 1

Scripts RND

Posted: Tue Apr 23, 2019 9:42 am
by cvespecialista
Hello, I'm new and my question is for MMB project.
I need to do a scripts lists and with the RightKey select one scripts from the list, is to random many data and select just one.
Excuse for bad english.
Thanks

Re: Scripts RND

Posted: Wed Apr 24, 2019 2:03 pm
by dgilmour
It's really hard to understand what you mean.

Re: Scripts RND

Posted: Wed Apr 24, 2019 3:03 pm
by cvespecialista
dgilmour wrote:It's really hard to understand what you mean.
I need to select from several scripts 1, at random

Re: Scripts RND

Posted: Wed Apr 24, 2019 6:18 pm
by dgilmour

Code: Select all

n = RND(9) + 1
label$ = 'Script ' + CHAR(n)
RunScript("label$")
This will run one of ten script objects with object name "Script n" where n is number from 1 to 10.

Re: Scripts RND

Posted: Thu Apr 25, 2019 8:24 pm
by cvespecialista
dgilmour wrote:

Code: Select all

n = RND(9) + 1
label$ = 'Script ' + CHAR(n)
RunScript("label$")
This will run one of ten script objects with object name "Script n" where n is number from 1 to 10.
Thank you for the code, but I could not to do with your specifications, could you to do an sample for me in .mbd, please.
Thank again.

Re: Scripts RND

Posted: Fri Apr 26, 2019 5:21 am
by Nigg
If you dont understand this example, I recommend to take a look at the (very good) MMB documentation.

Code: Select all

n = RND(9) + 1
define an integer variable "n" containing a number, using the random/rnd-function (see doc -> RND)

Code: Select all

label$ = 'Script ' + CHAR(n)
define a string variable "label" that returns the text "Script" and the random number from the integer variable "n" after it . "CHAR" makes it possible to use the integer value of "n" in the context of a string.

Code: Select all

RunScript("label$")
Run the script defined by the label$ variable ("Script" + the random number)... this could be "Script1", "Script2", "Script3" etc.